在android中删除草稿短信

时间:2012-12-04 11:47:24

标签: android

我想删除草稿短信。我可以删除收件箱短信。如何删除草稿短信?

提前致谢。

2 个答案:

答案 0 :(得分: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) { 

    } 
}

答案 1 :(得分:0)

尝试删除草稿短信

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