Reputation: 1566
I want to delete draft SMS. I am able to delete inbox SMS. How can i delete draft SMS ?
Thanks in advance.
Upvotes: 3
Views: 1952
Reputation: 6731
Try the code below
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) {
}
}
Upvotes: 1
Reputation: 132992
try as to delete draft SMS
this.getContentResolver().delete(Uri.parse("content://sms/draft"),
"_id=?", new String[]{"PASS_DRAFT_SMS_ID_HERE"});
Upvotes: 0