1

I am trying to implement searching onto phone and SIM contacts. Using lookup Uri I can search phone contacts. But I am unable to find any similar lookup Uri for searching into SIM directory.

I even tried including selection and selection arguments in my query to fetch only relevant contacts but still no success. It seems like the selection and selection arguments are simply ignored while executing query because I'm getting all the available SIM contacts.

My implementation to fetch particular contacts:

public Cursor getCursorForSIMContactsLike(Activity context,String constraint) {

        Uri uri = Uri.parse("content://icc/adn");
        String[] projection = new String[] { "_id", "name", "number" };
        String selection = "name LIKE ?";
        String[] selectionArgs = { constraint +"%" };
        String sortOrder = "name" + " COLLATE LOCALIZED ASC";

        return context.getContentResolver().query(uri, projection, selection,
                selectionArgs, sortOrder);
    }

Is there anything I'm doing wrong in this query? Or if anyone has any other techniques to perform searching over SIM contacts - please suggest.

4

0 回答 0