Tom Tom - 22 days ago 19
Android Question

Query error in Android

I ve tried this code to update all my values in column sync to 0... How can i solve this issue

public boolean updatesync()
{
SQLiteDatabase db=this.getWritableDatabase();

db.rawQuery("update patients set sync = '0'",null);

return true;
}


This code is not woriking... I need to change the entire column value of sync to 0. How can i do it.? I ve found this code as working when doing a search but not working for me. How can i solve it. Please help.....

Answer

Use execSQL() instead of rawQuery().

rawQuery() just compiles the SQL but does not execute it until the returned Cursor is moved. execSQL() both compiles and executes the SQL.

Comments