Request the last group of SMS messages by contact

Like the Message application, the first action displays the last SMS, grouped by person, and account number.

Example: I exchanged 50 texts with Chris, 60 with Alina, 40 with Rei ... The application displays something like this

Chris (50) Hey how are you lately ?    
Aline (60) Let catch up     
Ray   (40) Here is my number
Ethan (1)  I wrote a solution

I am trying to do the same. I request all SMS, then sort them. At least this is O (n) efficient.

Cursor cur = this.getContentResolver().query(Uri.parse("content://sms"), null, null, null, null);
int count = cur.getCount();

// iterate all the SMS
for (int i=1 ; i<=count ; i++){
    // processing
    ....

    cur.moveToNext();
}

Is there a way to request the latest messages (received or sent without a draft), grouped by person and receiving the amount of SMS from the person? I assume there are several queries.

+5
source share
1 answer

I think this will do what you want:

Cursor cur = this.getContentResolver().query(Uri.parse( "content://mms-sms/conversations?simple=true"), null, null, null, "normalized_date desc" );

.

+9

All Articles