无法通过编程方式删除短信。

3

我尝试过多种方法删除短信记录,包括但不限于线程ID、ID、WHERE子句等。

Android清单反映了读写权限。

我已经尝试了多种SMS内容的变化,例如来自收件箱等。

似乎没有任何方法可以删除记录。

以下是最后一次尝试:

    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();
        }


你正在测试哪个版本的安卓系统? - ianhanniballake
<uses-sdk android:minSdkVersion="8" android:targetSdkVersion="19" /> - user3730805
不好意思,请问您使用的设备/模拟器是哪个版本的安卓系统? - ianhanniballake
4.4.2 API 19,也在物理设备Galaxy S5上运行。 - user3730805
1个回答

2
Android 4.4 Kitkat引入了短信处理的更改,现在只有默认的短信应用程序被允许写入短信数据库 - 所有其他应用程序在尝试写入时都会默默失败。

1
谢谢!我更新了清单,重新运行了应用程序,它相应地删除了所有内容。 - user3730805

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接