Reputation: 3277
I am currently trying to delete a SMS from the SMS table from android. I used this to delete the SMS but there are errors. Is this the correct syntax? the messageID is the id of the message to be deleted.
Uri uriSMSURI = Uri.parse("content://sms/inbox/" + messageID);
getContentResolver().delete(uriSMSURI, null, null);
Upvotes: 0
Views: 4631
Reputation: 132992
for deleteing an sms you must add these permissions in AndroidManifest.xml:
<uses-permission android:name="android.permission.WRITE_SMS"> </ uses-permission>
<uses-permission android:name="android.permission.READ_SMS"> </ uses-permission>
URI's for reading and deleting sms:
//Available Uri string
String strUriInbox = "content://sms/inbox";//SMS_INBOX:1
String strUriFailed = "content://sms/failed";//SMS_FAILED:2
String strUriQueued = "content://sms/queued";//SMS_QUEUED:3
String strUriSent = "content://sms/sent";//SMS_SENT:4
String strUriDraft = "content://sms/draft";//SMS_DRAFT:5
String strUriOutbox = "content://sms/outbox";//SMS_OUTBOX:6
String strUriUndelivered = "content://sms/undelivered";//SMS_UNDELIVERED
String strUriAll = "content://sms/all";//SMS_ALL
String strUriConversations = "content://sms/conversations";//you can delete one conversation by thread_id
String strUriAll = "content://sms"//you can delete one message by _id
Upvotes: 4