I created a class extending SQLiteOpenHelper
to manage the connections to the database inside my app. The methods for insert, find, delete and list are working fine, but the method for update is not. This is its code:
public int updateEvent(Event event) {
SQLiteDatabase db = this.getWritableDatabase();
ContentValues values = new ContentValues();
values.put(KEY_EVENT_NAME, event.getName());
values.put(KEY_EVENT_DESCRIPTION, event.getDescription());
values.put(KEY_EVENT_DATE, event.getDate());
values.put(KEY_EVENT_ASSIST, event.getAssist());
int updatedRows = db.update(TABLE_EVENTS, values, KEY_EVENT_ID + " = ?",
new String[] { String.valueOf(event.getId()) });
db.close();
return i;
}
Debugging the app i saw that updatedRows
's value is 1, so i assume its doing it right. The problem is that, when i list the table again im not getting the actual values.
On the constructor im always sending the application Context for instantiate the database.
What am i doing wrong?
Thanks and regards
Aucun commentaire:
Enregistrer un commentaire