Reputation: 1477
I have a sqlite database which store different multiple user's data. I wanted to ask how to delete specific row in the database? I'm not really familiar with database type of stuff. Currently I have a delete function that used to delete one of the user's information in the database. But I'm not really sure how to delete the entire row. (I got emailid, first & last name and ssid in my database. )
public void delete_user(String ssid) {
Log.i(TAG,"delete_user ssid["+ssid+"]...");
String[] valuesWhere = new String[1];
valuesWhere[0] = ssid;
this.getWritableDatabase().delete("user", "ssid=?", valuesWhere);
}
Should I declare every value that I wanted to delete? I wanted to know whether is there another way that able to delete specific row of data. Any comments will be appreciated.
Upvotes: 0
Views: 297
Reputation: 86948
Should I declare every value that I wanted to delete? I wanted to know whether is there another way that able to delete specific row of data.
Your current code will delete every row that matches the ssid
passed to delete_user(ssid)
. If ssid
is a unique column (no duplicate values) it will delete one row at most.
But I'm not really sure how to delete the entire row.
Understand that SQLiteDatabase#delete()
will never partially delete a row.
Upvotes: 2