Code example for MockContentResolver

Methods: query

0
        return mResolver.query(ContentUris.withAppendedId(Contacts.CONTENT_URI, contactId),
                null, null, null, null); 
    } 
 
    protected Cursor queryContact(long contactId, String[] projection) {
        return mResolver.query(ContentUris.withAppendedId(Contacts.CONTENT_URI, contactId),
                projection, null, null, null);
    } 
 
    protected Uri getContactUriForRawContact(long rawContactId) {
        return ContentUris.withAppendedId(Contacts.CONTENT_URI, queryContactId(rawContactId));
    } 
 
    protected long queryContactId(long rawContactId) {
        Cursor c = queryRawContact(rawContactId);
        assertTrue(c.moveToFirst());
        long contactId = c.getLong(c.getColumnIndex(RawContacts.CONTACT_ID));
        c.close();
        return contactId;
    }