-1

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 working. I need to change the entire column value of sync to 0. How can I do that? I've found this code as working when searching, but it's not working for me. How can I solve that?

Please help.

Phantômaxx
  • 37,901
  • 21
  • 84
  • 115

2 Answers2

2

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.

laalto
  • 150,114
  • 66
  • 286
  • 303
0

for update value in Sqlite , try this one

public int updateName(string name,String Id){  
       ContentValues args = new ContentValues();
           args.put(KEY_NAME, name);
   return db.update(DATABASE_TABLE, args, KEY_ROWID + "=" + Id, null) > 0;
}

  *** Note *** 
  KEY_NAME= Column name (value will update),
  DATABASE_TABLE =Table name ,
  KEY_ROWID = Column name (value will update depends on this column name)
anu
  • 213
  • 1
  • 3
  • 10