My Android app needs to retrieve information about a contact (namely, phone number and name.) I wrote some code using getContentResolver().query()
In the results, I am seeing that the name is being returned, and other information like when I last contacted that person, but not the phone number. What am I doing wrong?
The code:
Log.w("MyApp", "requesting " + phonesUri.toString());
Cursor contactCursor = context.getContentResolver().query(person, null, null, null, null);
contactCursor.moveToFirst();
for (int i = 0; i < contactCursor.getColumnCount(); i ++) {
Log.w("MyApp", contactCursor.getColumnName(i) + ": " + contactCursor.getString(i));
}
which outputs this:
W/MyApp (21477): requesting content://contacts/people/169/phones
W/MyApp (21477): times_contacted: 6
W/MyApp (21477): custom_ringtone: null
W/MyApp (21477): primary_organization: null
W/MyApp (21477): phonetic_name:
W/MyApp (21477): status: null
W/MyApp (21477): label: null
W/MyApp (21477): number: null
W/MyApp (21477): type: null
W/MyApp (21477): mode: null
W/MyApp (21477): last_time_contacted: 1278113641980
W/MyApp (21477): display_name: (name removed for privacy)
W/MyApp (21477): im_handle: null
W/MyApp (21477): _id: 169
W/MyApp (21477): number_key: null
W/MyApp (21477): starred: 0
W/MyApp (21477): primary_email: null
W/MyApp (21477): name: (name removed for privacy)
W/MyApp (21477): primary_phone: null
W/MyApp (21477): im_account: null
W/MyApp (21477): notes:
W/MyApp (21477): im_protocol: null
W/MyApp (21477): send_to_voicemail: 0