我尝试过从短信中删除全部或部分消息的变体,包括但不限于线程 id、id、where 子句等。 Android list 反射(reflect)读写权限。 我尝试了 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();
}
最佳答案
引入 Android 4.4 Kitkat changes in SMS handling现在只有默认的 SMS 应用程序被允许对 SMS 数据库进行写入访问 - 所有其他应用程序在尝试写入时都会默默地失败。
关于android - 无法以编程方式删除短信,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24168336/