无法以编程方式删除SMS

时间:2014-06-11 16:48:31

标签: android sms

我尝试过删除SMS中的所有或部分消息的变体,包括但不限于线程ID,id,where子句等。 Android清单反映了读写权限。 我尝试了从收件箱等短信内容的变化。 似乎没有删除记录。

这是最后一次迭代:

    Cursor c = getApplicationContext().getContentResolver().query(Uri.parse("content://sms/"), null, null, null,null);
    try {
          while (c.moveToNext()) {
             int Id = c.getInt(0);
             String pid = c.getString(0);
            // String uri = "content://sms/conversations/" + threadId;
             String strUriAll = "content://sms/" + pid;//SMS_ALL
             Log.d("URI is ", strUriAll);
             getApplicationContext().getContentResolver().delete(Uri.parse(strUriAll), null, null);
          //   getApplicationContext().getContentResolver().delete(Uri.parse(strUriAll), null, null);
          }

        }catch(Exception e){
             Log.e(this.toString(),"Error deleting sms",e);
        }finally {
          c.close();
        }

    

1 个答案:

答案 0 :(得分:2)

Android 4.4 Kitkat推出了changes in SMS handling,现在只允许默认的SMS应用程序对SMS数据库进行写访问 - 所有其他应用程序在尝试写入时都会无声地失败。