-2

我的应用程序中有一个空闲数据库。如何删除任何行?我的数据库代码如下:

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

有谁知道这怎么可能?

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
4

2 回答 2

1

SQLDatabase对象有一个删除方法。public int delete (String table, String whereClause, String[] whereArgs)

mydb.delete(TABLE, "nickname = "+ DatabaseUtils.sqlEscapeString(name), null);
于 2012-07-04T15:49:47.280 回答
0
mydb.execSQL("DELETE FROM your_db.your_table WHERE  <write your SQL conditions here> ");  
于 2012-07-04T15:48:40.880 回答