Reading all contact data

蓝咒 提交于 2019-11-30 09:14:40

See Contact Contract API examples

http://www.higherpass.com/Android/Tutorials/Working-With-Android-Contacts/

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));
    String name = cur.getString(
                    cur.getColumnIndex(ContactsContract.Contacts.DISPLAY_NAME));
    if (Integer.parseInt(cur.getString(cur.getColumnIndex(ContactsContract.Contacts.HAS_PHONE_NUMBER))) > 0) {
        //Query phone here.  Covered next
        }
        }
}
}

Take a look at this example

http://code.google.com/p/android-contacts-contract-example/

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!