How to use SMS content provider? Where are the docs?

Mark picture Mark · Dec 29, 2009 · Viewed 43k times · Source

I'd like to be able to read the system's SMS content provider. Basically I wanted to make an SMS messaging app, but it would only be useful if I could see past threads etc.

It seems like there's a content provider for this, but I can't find documentation for it - anyone know where that is?

Thanks

-------- edit -----------

Ok I found a way to get the sms inbox provider, and I just dumped all the column names in that provider, looks like this:

Uri uriSms = Uri.parse("content://sms/inbox");
Cursor c = context.getContentResolver().query(uriSms, null,null,null,null); 

// column names for above provider:
0: _id
1: thread_id
2: address
3: person
4: date
5: protocol
6: read   
7: status
8: type
9: reply_path_present
10: subject
11: body
12: service_center
13: locked

I'm just piecing this together from random threads I find around the net, I'm really wondering where this is all documented (if at all)?

Thanks again

Answer

Avtar Guleria picture Avtar Guleria · Aug 24, 2011

In addition to those u can see the list of fields in sms content provider by using following code:

private void displaySmsLog() {
    Uri allMessages = Uri.parse("content://sms/");
     //Cursor cursor = managedQuery(allMessages, null, null, null, null); Both are same
    Cursor cursor = this.getContentResolver().query(allMessages, null,
            null, null, null);

    while (cursor.moveToNext()) {
        for (int i = 0; i < cursor.getColumnCount(); i++) {
            Log.d(cursor.getColumnName(i) + "", cursor.getString(i) + "");
        }
        Log.d("One row finished",
                "**************************************************");
    }

}