从收件箱短信中获取地址

时间:2014-06-25 05:59:08

标签: java android sms android-cursor inbox

我想从收件箱短信中获取地址
我不确定我的查询是否正确。

        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());
        }

1 个答案:

答案 0 :(得分:0)

喜欢

//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));

详细了解How to get column value from sqlite cursor?

相关问题