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

Popular posts from this blog

java - How to set log4j.defaultInitOverride property to false in jboss server 6 -

c - GStreamer 1.0 1.4.5 RTSP Example Server sends 503 Service unavailable -

Using ajax with sonata admin list view pagination -