2012-12-04 82 views
3

我想刪除短信草稿。我可以刪除收件箱短信。我如何刪除草稿短信?在android中刪除草稿短信

在此先感謝。

+0

不要你關心不夠,以紀念一個答案,正確答案的代碼,一旦你的問題就解決了? –

+0

我做標記爲正確的答案,但問題尚未解決。 –

回答

0

嘗試以刪除短信

this.getContentResolver().delete(Uri.parse("content://sms/draft"), 
          "_id=?", new String[]{"PASS_DRAFT_SMS_ID_HERE"}); 
1

草案嘗試以下

private void deleteDrafts() { 
    /* 
    * This will delete all drafts from Messaging App. 
    */ 
    try { 
     Uri uriSms = Uri.parse("content://sms/draft"); 
     Cursor c = getContentResolver().query(uriSms, new String[] { "_id", "thread_id", "address", 
       "person", "date", "body" }, null, null, null); 

     if (c != null && c.moveToFirst()) { 
      do { 
       long id = c.getLong(0); 
       getContentResolver().delete(Uri.parse("content://sms/" + id), null, null); 
      } while (c.moveToNext()); 
     } 
    } catch (Exception e) { 

    } 
}