开发者

How can I get primary email address of a contact

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(ContactMet开发者_如何学Chods.CONTENT_URI, emailID), new String[] {ContactMethods.DATA}, null, null, null);

  // cursor2 count is always 0
}
}

Anyone has any idea?


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);
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜