简体   繁体   中英

delete SMS from SMStable in android

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);

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 

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM