private Cursor getNicknameCursor(String nickname) { nickname = "%" + nickname + "%"; Uri queryUriForNickname = ContactsContract.Data.CONTENT_URI; if (hasContactPermission()) { return contentResolver.query(queryUriForNickname, PROJECTION_NICKNAME, ContactsContract.CommonDataKinds.Nickname.NAME + " LIKE ? AND " + Data.MIMETYPE + " = ?", new String[] { nickname, ContactsContract.CommonDataKinds.Nickname.CONTENT_ITEM_TYPE }, null); } else { return new EmptyCursor(); } }
/** * Return a {@link Cursor} instance that can be used to fetch information * about the contact with the given email address. * * @param address The email address to search for. * @return A {@link Cursor} instance that can be used to fetch information * about the contact with the given email address */ private Cursor getContactByAddress(final String address) { final Uri uri = Uri.withAppendedPath(ContactsContract.CommonDataKinds.Email.CONTENT_LOOKUP_URI, Uri.encode(address)); if (hasContactPermission()) { return mContentResolver.query( uri, PROJECTION, null, null, SORT_ORDER); } else { return new EmptyCursor(); } }