0

i'm unable to delete row in a table using sqlite 3.In my code i would like to compare two values an then delete the data in a table but it is not possible please help me.

 while(authCur.moveToNext())
 {
   db.delete("auth_tab",authCur.getString(0)+"=?" , new String[] { user }); 
       db.delete("auth_tab", null, null);   
      }
venkyMCA
  • 57
  • 1
  • 2
  • 13

1 Answers1

0

Deleting data

Once data is no longer needed it can be removed from the database with the delete() method. The delete() method expects 3 parameters, the database name, a WHERE clause, and an argument array for the WHERE clause. To delete all records from a table pass null for the WHERE clause and WHERE clause argument array.

   db.delete("auth_tab", "authCur.getString(0)=?", new String[] {user);

Simply call the delete() method to remove records from the SQLite database. The delete method expects, the table name, and optionally a where clause and where clause argument replacement arrays as parameters. The where clause and argument replacement array work just as with update where ? is replaced by the values in the array.

or

public void deleteContact(long id) {
    SQLiteDatabase db = this.getWritableDatabase();
    db.delete(auth_tab, KEY_USER + " = ?",
            new String[] { user) });
    db.close();
}

WATCH more, and you tube video, how to delete.

Community
  • 1
  • 1