• After 15+ years, we've made a big change: Android Forums is now Early Bird Club. Learn more here.

Apps Querying the SMS Content Provider

phil_mw60

Lurker
Hi All,

I'm having some problems querying the SMS content provider to obtain in my application. My code is as follows:

Code:
String columns[] = new String[] { "person"};
String url = "content://sms/inbox"; 
Uri uri = Uri.parse(url); 
 

Cursor cur = managedQuery(uri, 
columns, // Which columns to return
null, // WHERE clause; which rows to return(all rows)
null, // WHERE clause selection arguments (none)
null); // Order-by clause (ascending by name)

When I try to run this code in an emulator I get an error saying my application has to close.

Does anyone know why the above code would cause a problem? I think that "person" is one of the columns returned by the SMS content provider.

If anyone has any ideas where I am going wrong I would be very grateful! Also if anyone knows the rest of the columns provided by this content provider I would also be very greatful too...

thanks in advance,

Phil
 
In case anyone is interested I have managed to solve this...

it turned out to be a permissions issue.

I had to add the permission for READ_SMS to my androidmanifest.xml file and after doing this my code ran without any errors.
 
Hi,

I need to know the answer for your second question "Also if anyone knows the rest of the columns provided by this content provider I would also be very greatful too...
"

Thank you,
 
Column Names:

[0] "_id" (id=830102691400)
[1] "thread_id" (id=830102691464)
[2] "toa" (id=830102691536)
[3] "address" (id=830102691600)
[4] "person" (id=830102691672)
[5] "date" (id=830102691736)
[6] "protocol" (id=830102691800)
[7] "read" (id=830102691872)
[8] "status" (id=830102691936)
[9] "type" (id=830102692000)
[10] "reply_path_present" (id=830102692064)
[11] "subject" (id=830102692152)
[12] "body" (id=830102692224)
[13] "sc_toa" (id=830102692288)
[14] "report_date" (id=830102692352)
[15] "service_center" (id=830102692432)
[16] "locked" (id=830102692512)
[17] "index_on_sim" (id=830102692576)
[18] "callback_number" (id=830102692656)
[19] "priority" (id=830102692744)
[20] "htc_category" (id=830102692816)
[21] "cs_timestamp" (id=830102692896)
[22] "cs_id" (id=830102692976)
[23] "cs_synced" (id=830102693040)
[24] "error_code" (id=830102693112)
[25] "seen" (id=830102693184)
 
Back
Top Bottom