Reputation: 330
I'm trying to update a single attribute in a a single row. However, the code I have below is updating every row with the value of 'new description'.
public void editSingleLocation(String id, String new_description){
SQLiteDatabase db = this.getWritableDatabase();
ContentValues newValues = new ContentValues();
newValues.put(COLUMN_DESCRIPTION, new_description);
db.update(TABLE_LOCATIONS, newValues, KEY_ID=id, null);
i was trying to use one of the solutions in this link Android SQLite: Update Statement
but it doesn't seem to be working.
Upvotes: 1
Views: 319
Reputation: 330
fixed it:
the problem was with "KEY_ID=id"; it needed to be changed to:
db.update(TABLE_LOCATIONS, newValues, KEY_ID+"="+id, null);
Upvotes: 1