Jenya Kirmiza
Jenya Kirmiza

Reputation: 711

Android sql update

I am trying to update all rows in table and it's not working.

 String query="UPDATE "+TABLE_APPS+" SET "+KEY_APP_CHECK+" = '1'";
        SQLiteDatabase db = this.getWritableDatabase();
        db.rawQuery(query, null);
        db.close(); // Closing database connection

It doesn't show any exception but data is not updated

Upvotes: 1

Views: 66

Answers (2)

Mykhailo
Mykhailo

Reputation: 361

Is the best option:

ContentValues cvs = new ContentValues(); cvs.put(KEY_APP_CHECK, 1); db.update(TABLE_APPS, cvs, null, null);

Upvotes: 0

jauser
jauser

Reputation: 284

You should use db.execSQL instead of db.rawQuery to compile and run your sql.

Upvotes: 1

Related Questions