0

案例 1 效果很好,但案例 2 不起作用,有没有简单的方法来代替关键字 OR ?

情况1

public List<String> getSMS(int pos) {
        List<String> sms = new ArrayList<String>();
        Uri uriSMSURI = Uri.parse(valueList.get(pos));
        Cursor cur = getContentResolver().query(uriSMSURI, null,"_id= '6' or  _id= '4' ", null,
                null);

        while (cur.moveToNext()) {
            String address = cur.getString(cur.getColumnIndex("address"));
            String body = cur.getString(cur.getColumnIndexOrThrow("body"));
            sms.add("Number: " + address + " .Message: " + body+" CW  "+cur.getString(cur.getColumnIndex("_id")) );

        }
        return sms;
    }

案例2

public List<String> getSMS(int pos) {
        List<String> sms = new ArrayList<String>();
        Uri uriSMSURI = Uri.parse(valueList.get(pos));
        Cursor cur = getContentResolver().query(uriSMSURI, null,"_id in ['6','4'] ", null,
                null);

        while (cur.moveToNext()) {
            String address = cur.getString(cur.getColumnIndex("address"));
            String body = cur.getString(cur.getColumnIndexOrThrow("body"));
            sms.add("Number: " + address + " .Message: " + body+" CW  "+cur.getString(cur.getColumnIndex("_id")) );

        }
        return sms;
    }
4

1 回答 1

1

在你的情况下试试这个 2..

Cursor cur = getContentResolver().query(uriSMSURI, null,"_id in ('6','4') ", null,
                null);

看看这是否有效...

于 2013-05-19T07:42:31.417 回答