mardi 16 février 2016

SQLite autoincrement primary key fields dont allow update

I have got a database table with a column "id INTEGER PRIMARY KEY AUTOINCREMENT". When I try to update an existing row of this table with the primary key the app exits saying "Unfortunately is stopped."

Ex record : id, name, age ---> 1, "John", 21.

I need to update it as 1, "Albert", 25.

SQLiteDatabase db = this.getWritableDatabase();
db.update(TABLE_USERS, values, KEY_ID + " = ?",
            new String[] { String.valueOf(user.getUser_id()) });

There is no any errors in the whole thing. Only stopping problem. But the rest works well when I comment therse update query. Can some one give a solution please ? Thank you.

Aucun commentaire:

Enregistrer un commentaire