0

I want to get addresses from Inbox SMS Messages
I am not sure if my query is correct.

        final String SMS_URI_INBOX = "content://sms/inbox";

        Uri uri = Uri.parse(SMS_URI_INBOX);
        String[] projection = new String[] { "_id", "address", "person", "body", "date", "type" };
        Cursor cur = getContentResolver().query(uri, projection, "address='?'", null, "address ASC");

        List<String> spinnerArray =  new ArrayList<String>();

        if (cur.moveToFirst())
        {
            do
            {
                //How to get address
                 spinnerArray.add(address);

            } while (cur.moveToNext());
        }
Saleh Feek
  • 2,018
  • 7
  • 33
  • 55

1 Answers1

0

Do like

//How to get address      
spinnerArray.add(cur.getString(cur.getColumnIndex("address")));
// OR position of address column into projection is at 2 so you can pass
// direct.         
spinnerArray.add(cur.getString(1));

Read more about How to get column value from sqlite cursor?.

Community
  • 1
  • 1
Pankaj Kumar
  • 81,071
  • 26
  • 167
  • 187