【问题标题】:deleting sms from thread SQLite Exception从线程 SQLite 异常中删除短信
【发布时间】:2016-07-25 17:09:36
【问题描述】:

我正在开发一个应用程序,当收到短信时,它会存储在 sqlite 数据库中并显示在 Listview 中。如果从同一号码接收到不同的短信,则短信以线程的形式保存,就像在普通消息传递应用程序中一样。 现在的问题是我无法删除号码内的内部消息。我可以删除整个线程,但不能删除线程内的一条一条消息。 不知道为什么会这样。 这是创建表的查询:

public static final String query_createSMSTablee = "create table " + "smss" + "(" + "id" + " integer primary key autoincrement, "
      + "contactnumber" + " text, " + "contactname" + " text," + "message" + " text," + "date" + " text)";

现在将消息作为线程我这样做了:

String query = "select  message  from " + "smss"+ " where " + "contactnumber" + " = \"" + mdataa + "\"" ;

其中“mdataa”包含发件人的号码。 "message" 只包含消息内容 所以通过这种方式,这变成了一个线程,即只显示来自线程内特定数字的消息。 现在,当我长按消息并尝试通过此查询删除时,这会显示错误:

String deleteScreenedMessage = "delete from " + "smss" + " where " + "id" + " = \"" + id + " AND " + "message" + " = \"" + selectedFromList + " AND " + "contactnumber" + " = \"" + mdataa + "\"" ;
DBtableforNotSpam smsDb = new DBtableforNotSpam(Conversation.this);
SQLiteDatabase dbw = smsDb.getWritableDatabase();
dbw.execSQL(deleteScreenedMessage);
dbw.close();

这里“selectedFromList”代表消息的内容,mdataa包含发送者的号码。 但是这个查询给出了强制停止错误并说 Sqlite 异常。 请帮助任何人

【问题讨论】:

  • 总是需要添加崩溃日志
  • 我要编辑帖子
  • 您的错误日志清楚地表明您的 sql 查询中缺少引号,请检查它
  • 我检查了很多次,但我仍然没有在查询中找到任何东西:(

标签: android sqlite sms


【解决方案1】:

您的查询字符串不正确,您在使用引号,

试试这个查询,

String deleteScreenedMessage = "delete from " + "smss" + " where " + "id" + " 
       = " + id + " AND " + "message" + "='" + selectedFromList + "' AND " + 
                                                "contactnumber" + " ='" + mdataa +"'" ;

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2023-03-05
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-10-18
    • 2017-12-03
    相关资源
    最近更新 更多