尝试删除行时出现SQLite异常 [英] SQLite exception while trying to delete row

查看:254
本文介绍了尝试删除行时出现SQLite异常的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我遇到错误:

android.database.sqlite.SQLiteException:在:BE"附近:语法错误 (代码1):,编译时:从设备WHERE中删除 地址= C4:BE:84:18:D5:A5

android.database.sqlite.SQLiteException: near ":BE": syntax error (code 1): , while compiling: DELETE FROM device WHERE address=C4:BE:84:18:D5:A5

尝试从sqlite数据库中删除行时.

while trying to remove row from sqlite database.

public int removeDevice(String address) {
  open();
  int removedId = database.delete(MySQLiteHelper.TABLE_DEVICE
                , MySQLiteHelper.KEY_ADDRESS +  "=" + address, null);
  close();

  return removedId;
}

我不知道怎么了.

推荐答案

尝试一下.

int removedId = database.delete(MySQLiteHelper.TABLE_DEVICE
            , MySQLiteHelper.KEY_ADDRESS +  "= ?",new String[] {address});

这篇关于尝试删除行时出现SQLite异常的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆