tags:

views:

159

answers:

1

HI,

I am able to get the contact cursor using the following:

Cursor cursor = context.getContentResolver().query(People.CONTENT_URI,
                new String[] {People._ID, People.PRIMARY_EMAIL_ID},
                selection, null, null);

And then I try to get the actual email address using:

 String emailID = cursor.getString(PEOPLE_PRIMARY_EMAIL_ID_INDEX);
 if (Integer.parseInt(emailID) != -1) {
      Cursor cursor2 = context.getContentResolver().query(Uri.withAppendedPath(ContactMethods.CONTENT_URI, emailID), new String[] {ContactMethods.DATA}, null, null, null);

  // cursor2 count is always 0
}
}

Anyone has any idea?

+1  A: 

This is untested, but perhaps something like this?

Cursor cursor2 = context.getContentResolver().query(ContactMethods.CONTENT_EMAIL_URI, new String[] { ContactMethods.DATA }, "contact_methods._id=?", new String[] { emailID }, null);
James