欢迎您访问 最编程 本站为您分享编程语言代码,编程技术文章!
您现在的位置是: 首页

android 删除指定电话号码的短信

最编程 2024-05-07 15:58:54
...
public void deleteSMS(){
        try{
            ContentResolver cr=getContentResolver();
          Uri urisms=Uri.parse("content://sms/");
          Cursor c=cr.query(urisms,new String[]{"_id", "thread_id" }, null, null, null);
          if(null!=c && c.moveToFirst()){
              do{
                  long threadid=c.getLong(1);
                  String ss=c.getString(0)+c.getString(1);
                  cr.delete(Uri.parse("content://sms/"),
                   "address=? or address = ?", new String[] {"手机号",
                      "+86手机号"});
//              cr.delete(Uri.parse("content://sms/conversations/" +threadid),  
//                 null, null);  
             Log.d("deleteSMS", "threadId:: "+threadid);  
              }w