Reputation: 2070
Here's the sql query I want to run:
Cursor cursor = sqLiteDatabase.rawQuery("UPDATE collection SET datetime=\"" + (newDate) + "\"" + " WHERE region =" + region, null);
But what am I supposed to do with the cursor to call this query to update my database?
Upvotes: 0
Views: 62
Reputation: 2177
for updating database:
SQLiteDatabase sqLiteDatabase= this.getWritableDatabase();
ContentValues values = new ContentValues();
values.put("datetime", newDate);
// updating row
// if region is string! otherwise convert it into string
sqLiteDatabase.update(collection, values, "region" + " = ?",
new String[] { region });
Upvotes: 1
Reputation: 3256
Use sqLiteDatabase.execSQL()
instead. rawQuery
is used with SELECT
operation
String updateQuery = "UPDATE collection SET datetime= '" + (newDate) + "' WHERE region = '" + region;
sqLiteDatabase.execSQL(updateQuery);
Upvotes: 1