I am trying to select a phone number from a global address book (Corporate account). I would like to use the native picker/API because I don't want to prompt the user for login credentials. I came across the ContactsContract.Directory API. However, I couldn't find any samples on how to use it. I tried:
private static final String[] PEOPLE_PROJECTION = new String[] {
ContactsContract.Directory._ID,
ContactsContract.Directory.DISPLAY_NAME,
};
StringBuilder buffer = null;
String[] args = null;
if (constraint != null) {
buffer = new StringBuilder();
buffer.append("UPPER(");
buffer.append(Phone.DISPLAY_NAME);
buffer.append(") GLOB ?");
args = new String[] { constraint.toString().toUpperCase() + "*" };
}
Cursor c = getContentResolver().query(ContactsContract.Directory.CONTENT_URI, PEOPLE_PROJECTION, buffer == null ? null : buffer.toString(), args, null);
But c always returns null. Please note that I am trying to retrieve just the DISPLAY_NAME here, as I am not sure how to retrieve the phone number yet. Thanks for your help.