Search code examples
androidsqlitesmsandroid-contentprovider

Sort SMS messages in ascending order


When I query the SMS provider in Android I get the messages in from the older ones to the most recent ones. I am using the following query:

Cursor cursor = getContentResolver().query(messagesUri,null,null,null,null);

Is it possible to sort it the opposite way?


Solution

  • The solution is to transform the last argument from null to date ASC:

    Cursor cursor = getContentResolver().query(messagesUri,null,null,null,"date ASC");