I have names and id's from listview in two different arraylist and what i want is to store id's and names from arraylist to string and then save them on a button click to sqlite. problem with below code is that when two items are check and button is clicked the items are inserting twice.and when the id is set as UNIQUE then on insertion to 3 id's only one is saving in sqlite,...
this is what i done so far.....
public void addSelected(ArrayList<String> selNames, ArrayList<String> selID) {
SQLiteDatabase db = getWritableDatabase();
try{
for (String str: selID){
for (String stl:selNames){
ContentValues cv = new ContentValues();
cv.put(KEY_ID, str);
cv.put(KEY_STATUS, stl);
db.insertOrThrow(TABLE_SELECTED, null, cv);
}
}
db.close();
}catch (Exception e){
Log.e("Problem", e + " ");
}
}
Aucun commentaire:
Enregistrer un commentaire