Dipin.K.G Dipin.K.G - 24 days ago 6
Android Question

Delete my DataBase row

I have a idless DataBase in my application how can I delete any of the row?
Yy database code as follows:

mydb=Nickname.this.openOrCreateDatabase("private", 0, null);
mydb.execSQL("CREATE TABLE IF NOT EXISTS numbers(nickname varchar,number INT(13))");


Anyone know how it is possible?

mydb=Clear.this.openOrCreateDatabase("private", 0, null);
mydb.execSQL("CREATE TABLE IF NOT EXISTS numbers(_id INTEGER PRIMARY KEY,nickname varchar,number INT(13))");
mydb.execSQL("DELETE FROM numbers WHERE id='=?' AND number='"+num+"'");

//num is string which contains which number i wish to delete

Answer

The SQLDatabase object has a delete method. public int delete (String table, String whereClause, String[] whereArgs)

mydb.delete(TABLE, "nickname = "+ DatabaseUtils.sqlEscapeString(name), null);
Comments