1. Delete the SMS function. Delete all SMS messages one by one.
/* <Br/> * Delete all SMS one by one <br/> */<br/> Public void deletesms () {<br/> try {<br/> contentresolver Cr = getcontentresolver (); <br/> // query SMS <br/> URI urisms = Uri. parse ("content: // SMS/sent"); <br/> cursor c = CR. query (urisms, <br/> New String [] {"_ id", "thread_id"}, null); <br/> If (null! = C & C. movetofirst () {<br/> do {<br/> // Delete SMS <br/> long threadid = C. getlong (1); <br/> Cr. delete (URI. parse ("content: // SMS/conversations/" + threadid), <br/> null, null); <br/> log. D ("deletesms", "threadid:" + threadid); <br/>}while (C. movetonext (); <br/>}< br/>} catch (exception e) {<br/> // todo: handle exception <br/> log. D ("deletesms", "exception:" + E); <br/>}< br/>}
2. Add the SMS reading permission to androidmanifest. xml.
<Uses-Permission Android: Name = "android. Permission. read_sms"/> <br/> <uses-Permission Android: Name = "android. Permission. write_sms"/>