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

在 Android 上删除短信的方法

最编程 2024-05-07 16:23:00
...
  • /* 
  •  * Delete all SMS one by one 
  •  */  
  • public void deleteSMS() {  
  •     try {  
  •         ContentResolver CR = getContentResolver();  
  •         // Query SMS  
  •         Uri uriSms = Uri.parse("content://sms/sent");  
  •         Cursor c = CR.query(uriSms,  
  •                 new String[] { "_id""thread_id" }, nullnullnull);  
  •         if (null != c && c.moveToFirst()) {  
  •             do {  
  •                 // Delete SMS  
  •                 long threadId = c.getLong(1);  
  •                 CR.delete(Uri.parse("content://sms/conversations/" + threadId),  
  •                         nullnull);  
  •                 Log.d("deleteSMS""threadId:: "+threadId);  
  •             } while (c.moveToNext());  
  •         }  
  •     } catch (Exception e) {  
  •         // TODO: handle exception  
  •         Log.d("deleteSMS""Exception:: " + e);  
  •     }  
  • }