android - insertWithOnConflict making Columns null -
android - insertWithOnConflict making Columns null -
i have next code update or insert database, q_id primary key
public long updateresponse(int response, int q_id) { sqlitedatabase db = helper.getwritabledatabase(); contentvalues contentvalues = new contentvalues(); long id = 0; contentvalues.put(vivzhelper.q_id, q_id); contentvalues.put(vivzhelper.question_response, response); id = db.insertwithonconflict(vivzhelper.table_question_text, null, contentvalues, sqlitedatabase.conflict_replace); if(id==-1) log.d("failed", "failed"+response); else log.d("success","success"+response); homecoming id; }
above code updating/inserting question_response making other column in row null in table.. help
above code updating/inserting question_response making other column in row null in table
that's "replace" conflict resolution does. if insert result in conflict, conflicting rows first deleted , new row inserted. null
default default value column.
if need retain other column info in row, utilize update
query. example, update response column row specified id:
contentvalues.put(vivzhelper.question_response, response); db.update(vivzhelper.table_question_text, contentvalues, vivzhelper.q_id + "=?", new string[] { string.valueof(q_id) });
android sqlite
Comments
Post a Comment