I am trying to create an sms conversation list. I am using this code to get a cursor:
Cursor cursor = activity.getContentResolver().query(Uri.parse(\"conten
Querying the "content://sms/conversations"
URI (Telephony.Sms.Conversations.CONTENT_URI
) will return a summary of each conversation, with the "snippet"
column (Telephony.Sms.Conversations.SNIPPET
) being the last message in each.
This query will also return with a "msg_count"
column (Telephony.Sms.Conversations.MESSAGE_COUNT
) - which is pretty self-explanatory - and a "thread_id"
column (Telephony.Sms.Conversations.THREAD_ID
), which can be used to retrieve a complete conversation, by querying with that ID appended to the conversations URI. For example:
String threadId = ...
Uri convoUri = Telephony.Sms.Conversations.CONTENT_URI
.buildUpon().appendPath(threadId).build();
Do note that these queries will return only SMS messages. If you want MMS as well, Telephony.Mms
and Telephony.MmsSms
have similar URIs.