Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android Telephony.Sms.Conversations

How can Telephony.Sms.Conversations be used to retrieve convo information to String?

I tried:

ContentResolver cr = context.getContentResolver();
Cursor convo = cr.query(Telephony.Sms.Conversations.CONTENT_URI,
                        new String[] { Telephony.Sms.Conversations.ADDRESS,
                                       Telephony.Sms.Conversations.PERSON },
                        null,
                        null,
                        Telephony.Sms.Conversations.DEFAULT_SORT_ORDER);

How ever I get error invalid column address. when I remove address I get invalid column person. What column's does this class provide? (I couldn't find anything on the API reference page or any examples online. btw I already have a working code to retrieve inbox and outbox but I would like to get conversations too (I mean title and num of msges), without matching inbox and outbox results)

like image 468
Arijoon Avatar asked Feb 13 '26 05:02

Arijoon


1 Answers

You can only get "msg_count" and "snippet" values from Telephony.Sms.Conversations, and you can get the "address" value from Telephony.TextBasedSmsColumns.

private static final String[] SMS_CONVERSATIONS_PROJECTION = new String[]{"msg_count", "snippet"};
Cursor cursor = cr.query(Telephony.Sms.Conversations.CONTENT_URI,
            SMS_CONVERSATIONS_PROJECTION, null, null,Telephony.Sms.Conversations.DEFAULT_SORT_ORDER);
while(cursor.moveToNext()) {
    int msg_count = cursor.getInt(cursor.getColumnIndex("msg_count"));
    String snippet = cursor.getString(cursor.getColumnIndex("snippet"));
}
cursor.close;

It's inconvenient for us without "address", "date" and so on.
Telephony.Sms.Conversation

like image 104
lovefish Avatar answered Feb 15 '26 18:02

lovefish