简体   繁体   中英

how to delete rows in a table on database using android sqlite3

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);   
      }

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 .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM