I'm currently developing an android app with eclipse. I got a problem while updating the database. The problem is the app crash while the updateFlag method is called. The updateFlag method only update one specific column only based on the rowId.
This is my database structure in SQLiteAdapter class:
public long insert(String answer, String question, String hint, String flag, String level){
ContentValues contentValues = new ContentValues();
contentValues.put(KEY_ANSWER, answer);
contentValues.put(KEY_QUESTION, question);
contentValues.put(KEY_HINT, hint);
contentValues.put(KEY_FLAG, flag);
contentValues.put(KEY_LEVEL, level);
return sqLiteDatabase.insert(MYDATABASE_TABLE, null, contentValues);
}
This is the update method in SQLiteAdapter class:
public void updateFlag(long rowId)
{
ContentValues args = new ContentValues();
args.put(KEY_FLAG, "1");
sqLiteDatabase.update(MYDATABASE_TABLE, args, KEY_ROWID + "=" + rowId, null);
}
And this is how I call the updateFlag method in another class:
mySQLiteAdapterListener2 = new SQLiteAdapter(this);
mySQLiteAdapterListener2.openToWrite();
long idListener = Long.parseLong(getId);
mySQLiteAdapterListener2.updateFlag(idListener);
mySQLiteAdapterListener2.close();
What's wrong with my code? Anyone know how to update one specific column based on rowId in the right way?