I have an Android app that displays user SMS's in a threaded conversation format; that is with each item showing the display name (if available), contact photo, MSISDN and timestamp/teaser for the most recent incoming or outgoing message in the conversation.
Problem is that it's actually not so easy to do this in Android. Querying the threads directly returns limited information, so timestamps, for example, are not available. Querying all messages will return all the data I want, but then I have to sort through it all, find the most recent message, tot-up conversation size totals and so on. As an added complication, drafts are custom (not the standard ones held with all the other messages) and also have to be added to the mix.
This latter approach has led to a monstrous approach, using the latter, whereby I grab everything, sort through it all which sees the data go from a Cursor to HashMap to a List and finally an adapter is used for display purposes. This naturally leads to a serious performance issue whereby the user has to wait a few seconds for the screen to refresh.
So the question I have is whether there is a more efficient way of doing this, for example querying the messages using raw SQL, that would not result in such a big hit on performance?