Accessing the SMS inbox is another common requirement. First, you must grant the permission to read the SMS
Add to description file. After adding this permission, you can read short messages in the SMS inbox.
To read SMS messages, you must query the SMS inbox. The following is our code list.
Layout File
Our custom ListActivity
The above code opens the SMS inbox and creates a list. Each item in the list contains the body of the SMS message. Our layout file only contains a simple TextView, which contains the body of each message in the list. To obtain the message list, you can create a URI (content: // SMS/inbox) pointing to the sms inbox and perform a simple query. Then, filter the text of the SMS message and set the ListActivity list adapter. Execute the above Code to see the message in the inbox, as shown below.
Make sure that your inbox contains SMS messages.
Because you can access the SMS inbox, you can access other SMS-related folders, such as the sent folder or draft box folder. The only difference between accessing the inbox and accessing other folders lies in the specified URI. For example, you can query content: // sms/sent to access the sent folder. The following is a complete list of SMS folders and the URI of each folder.
All Folders: content: // sms/all
Inbox: content: // sms/inbox
Sent: content: // sms/sent
Draft: content: // sms/draft
Sender: content: // sms/outbox
Failed to send: content: // sms/failed
Queue message: content: // sms/queued
Not delivered: content: // sms/undelivered
Conversation: content: // sms/conversations