Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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

like image 595
Mark Avatar asked Dec 29 '09 18:12

Mark


People also ask

How do you read data from a content provider?

To retrieve data from a provider, your application needs "read access permission" for the provider. You can't request this permission at run-time; instead, you have to specify that you need this permission in your manifest, using the <uses-permission> element and the exact permission name defined by the provider.

How do you initialize a content provider?

The primary methods that need to be implemented are: onCreate() which is called to initialize the provider. query(Uri, String[], Bundle, CancellationSignal) which returns data to the caller. insert(Uri, ContentValues) which inserts new data into the content provider.


1 Answers

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",                 "**************************************************");     }  } 
like image 164
Avtar Guleria Avatar answered Oct 02 '22 16:10

Avtar Guleria