Querying the SMS Content Provider


Last Updated:

  1. phil_mw60

    phil_mw60 Member This Topic's Starter

    Joined:
    Jul 28, 2010
    Messages:
    8
    Likes Received:
    0
    Hi All,

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

    Code (Text):
    1.  
    2. String columns[] = new String[] { "person"};
    3. String url = "content://sms/inbox";
    4. Uri uri = Uri.parse(url);
    5.  
    6.  
    7. Cursor cur = managedQuery(uri,
    8. columns, // Which columns to return
    9. null, // WHERE clause; which rows to return(all rows)
    10. null, // WHERE clause selection arguments (none)
    11. null); // Order-by clause (ascending by name)
    12.  

    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
     

    Advertisement
  2. phil_mw60

    phil_mw60 Member This Topic's Starter

    Joined:
    Jul 28, 2010
    Messages:
    8
    Likes Received:
    0
    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.
     
  3. hazhir

    hazhir New Member

    Joined:
    Sep 3, 2010
    Messages:
    2
    Likes Received:
    0
    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,
     
  4. CHESS4U

    CHESS4U New Member

    Joined:
    Jan 20, 2011
    Messages:
    1
    Likes Received:
    0
    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)
     

Share This Page

Loading...