samedi 11 avril 2015

insertWithOnConflict making Columns null

I have the following code to update or insert database, where q_id is my 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);
return id;
}


Above code is updating/inserting QUESTION_RESPONSE but making all other column in that row as null in table.. Help


Aucun commentaire:

Enregistrer un commentaire