Reputation: 1588
Well I am trying to update a value in database false to true;
this is my code
public void updatecheck( int id){
mDb = mDbHelper.getWritableDatabase();
ContentValues newValues = new ContentValues();
newValues.put("check", true);
mDb.update(channel, newValues, "id"+" = ?", new String [] {String.valueOf(id)});
}
But I am taking this error,
02-28 15:15:37.515: E/AndroidRuntime(5539): android.database.sqlite.SQLiteException: near "check": syntax error (code 1): , while compiling: UPDATE Genelkultur2012 SET check=? WHERE id = ?
SOLVED:
new codes
ContentValues newValues = new ContentValues();
newValues.put("tamam", true);
mDb.update(channel, newValues, "id"+" = ?", new String [] {String.valueOf(id)});
Upvotes: 0
Views: 85
Reputation: 152817
CHECK
is a reserved keyword in SQL. Either rename the column or quote it in backticks.
Upvotes: 3
Reputation: 3076
newValues.put("check", true);
You're trying to store true, a Boolean data type, which is not supported by SQLite. You'll instead have to store them in one of the following types:
I'd suggest to store Boolean members as 0 or 1. More info here: http://www.sqlite.org/datatype3.html
Upvotes: 1