Search code examples
androidsmsmms

How do I sort SMS and MMS together?


I'm implementing the methods discussed here: How to Read MMS Data in Android?

I'm trying to read SMS and MMS into a single listview. I'm doing pretty well, but when I try to sort I'm getting all of the SMS sorted together followed by all of the MMS sorted together.

Here is my code:

Cursor smsCursor = getContentResolver().query(Uri.parse("content://mms-sms/conversations/"), null, null, null, "date DESC");

Can anyone tell me how to combine the two sources or how to combine the MMS into the SMS conversations like the built in Android app does?

Edit: I noticed that the date of SMS has several more digits than the dates of MMS.

Edit 2: Adding "julianday()" like so:

Cursor smsCursor = getContentResolver().query(Uri.parse("content://mms-sms/conversations/"), null, null, null, "julianday(date) DESC");

Makes the MMS appear at the top of the list.


Solution

  • try normalized_date desc instead of date desc for the order.

    It should work.