开发者

getting the email of the contacts phone android [duplicate]

This question already has answers here: 开发者_高级运维 How to read contacts on Android 2.0 (9 answers) Closed 9 years ago.

Hi how Can I get the list emails of my contacts ? I want to display this list of emails in spinner. thanks


ContentResolver cr = getContentResolver();
Cursor cur = cr.query(ContactsContract.Contacts.CONTENT_URI,null, null, null, null);
if (cur.getCount() > 0)
{
  while (cur.moveToNext())
  {
    String id = cur.getString(
                      cur.getColumnIndex(ContactsContract.Contacts._ID));
    Cursor pCur = cr.query(
          ContactsContract.CommonDataKinds.Email.CONTENT_URI, 
          null, 
          ContactsContract.CommonDataKinds.Email.CONTACT_ID +" = ?", 
          new String[]{id}, null);


    while (pCur.moveToNext())
    {
        String email = pCur.getString(
            pCur.getColumnIndex(ContactsContract.CommonDataKinds.Email.DATA));
        // your email handling code would go in here
    } 
    pCur.close();
  }
}

?

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜