contentValues.clear() | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

contentValues.clear()

Hi, Please tell me, why <clear()> is used in the code bellow? Is it realy needed? ContentValues contentValues = new ContentValues(); db.execSQL("create table position (" + "id integer primary key, " + "name text, " + "salary integer" + ");"); for(int i = 0; i < position_id.length; i++) { contentValues.clear(); // ?? contentValues.put("id", position_id[i]); contentValues.put("name", position_name[i]); contentValues.put("salary", position_salary[i]); db.insert("position", null, contentValues);

12th Jun 2019, 9:19 PM
Yuri Kurashov
Yuri Kurashov - avatar
1 Answer
+ 2
Clear() is a method of ContentValues which possibly extends Arraylist I dont think this is the full code so its difficut say but if it is then clear(); removes all elements from the list.
12th Jun 2019, 11:58 PM
D_Stark
D_Stark - avatar