Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/217.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android 无法以编程方式删除SMS_Android_Sms - Fatal编程技术网

Android 无法以编程方式删除SMS

Android 无法以编程方式删除SMS,android,sms,Android,Sms,我尝试过从SMS中删除所有或部分消息,包括但不限于线程id、id、where子句等。 Android清单反映了读写权限。 我尝试了不同的短信内容,从收件箱等。 似乎没有任何东西可以删除该记录 这是最后一次迭代: Cursor c = getApplicationContext().getContentResolver().query(Uri.parse("content://sms/"), null, null, null,null); try { while

我尝试过从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();
        }

Android 4.4 Kitkat现在只允许默认的SMS应用程序对SMS数据库进行写访问-所有其他应用程序在尝试写时都会以静默方式失败。

您在哪个版本的Android上测试此功能?不,您使用的设备/模拟器是哪个版本的Android 4.4.2 api 19,也在物理设备Galaxy S5上运行谢谢!我更新了清单,重新运行了应用程序,它相应地删除了所有内容。