我收到错误:
尝试从sqlite数据库中删除行时android.database.sqlite.SQLiteException:near“:BE”:语法错误 (代码1):,同时编译:DELETE FROM device WHERE 地址= C4:BE:84:18:D5:A5
。
public int removeDevice(String address) {
open();
int removedId = database.delete(MySQLiteHelper.TABLE_DEVICE
, MySQLiteHelper.KEY_ADDRESS + "=" + address, null);
close();
return removedId;
}
我无法弄清楚出了什么问题。
答案 0 :(得分:2)
使用带单引号的地址
DELETE FROM device WHERE address='C4:BE:84:18:D5:A5'
答案 1 :(得分:1)
试试这个。
int removedId = database.delete(MySQLiteHelper.TABLE_DEVICE
, MySQLiteHelper.KEY_ADDRESS + "= ?",new String[] {address});
答案 2 :(得分:1)
使用它:
sqLiteDatabase.delete(" Table"," row =?",new String [] {String.valueOf(value)});