Find and interate all SMS/MMS messages in android

Viewed 6252

First and foremost, I found this answer particularly helpful. However, it made me wonder how one goes about finding such information.

I can't seem to figure out how to iterate all the messages in my inbox. My current solution uses Uri.parse("content://mms-sms/conversations") in which I give use "_id" and "ct_t". However, it seems I only find the three conversations in my phone despite having 30 msges (20 of them in the save conversation thread and the others divided between two other conversations). Would make sense for such a statement content://mms-sms/conversations. However, the other providers seem to deal only with SMS OR MMS. Isn't there a way to just iterate the entire list of messages in this fashion where I replace "content://mms-sms/conversations" with something else?

public boolean refresh() {
    final String[] proj = new String[]{"_id","ct_t"};
    cursor = cr.query(Uri.parse("content://mms-sms/conversations"),proj,null,null,null);
    if(!(cursor.moveToFirst())) {
        empty = true;
        cursor.close();
        return false;
    }
    return true;
}

I iterate the messages with a next function

    public boolean next() {

        if(empty) {
            cursor.close();
            return false;
        }
        msgCnt = msgCnt + 1;

        Msg msg;
        String msgData = cursor.getString(cursor.getColumnIndex("ct_t"));
        if("application/cnd.wap.multipart.related".equals(msgData)) {
            msg = ParseMMS(cursor.getString(cursor.getColumnIndex("_id")));
        } else {
            msg = ParseSMS(cursor.getString(cursor.getColumnIndex("_id")));
        }


        if(!(cursor.moveToNext())) {
            empty = true;
            cursor.close();
            return false;
        }

        return true;
    }
2 Answers
Related