jeudi 10 septembre 2015

The same whereClause and whereArgs works in query method and does not in update method

I have an android app. When I use SQLiteDatabase.query with a whereClause and whereArgs it returns a cursor with with count 1. when I use SQLiteDatabase.update with the same whereClause and whereArgs it returns 0 affected row.

int rows = 0;
int r = 0;
Cursor c = sqLiteDatabase.query(Linker.TABLE_NAME,null,Linker.COLUMN_NAME_QUESTION_LINK
                        + " = ? AND " + Linker.COLUMN_NAME_ANSWER_LINK + " = ? AND " + Linker.COLUMN_NAME_FIELD_LINK + " IS NULL",
                        new String[] {question,answer},null,null,null);
                r = c.getCount(); // r becomes 1
rows = sqLiteDatabase.update(Linker.TABLE_NAME,contentValues, Linker.COLUMN_NAME_QUESTION_LINK
                        + " = ? AND " + Linker.COLUMN_NAME_ANSWER_LINK + " = ? AND " + Linker.COLUMN_NAME_FIELD_LINK + " IS NULL",
                        new String[] {question,answer}); // row value still 0

Please where is the problem? and how can I solve it?

Aucun commentaire:

Enregistrer un commentaire