android sdk 1.6 -2.1获取通讯录内容

1.6获取方法

     ContentResolver resolver = getContentResolver();
     Cursor cursorPhone = resolver.query(People.CONTENT_URI,
      null,null , null,null);

2.1     获取方法

ContentResolver resolver = getContentResolver();
     Cursor cursorPhone = resolver.query(ContactsContract.Contacts.CONTENT_URI
      null,null , null,null);

1.6将电话号码也放在同一个ContentProvider里,

而2.1将号码放到了ContactsContract.CommonDataKinds.Phone.CONTENT_URI

仅获取手机号码:

ContentResolver resolver = getContentResolver();

    Cursor cursorPhone = resolver.query(ContactsContract.CommonDataKinds.Phone.CONTENT_URI,        null,ContactsContract.CommonDataKinds.Phone.TYPE+"="+ContactsContract.CommonDataKinds.Phone.TYPE_MOBILE , null,null);

 

记得在Manifest.xml里加上访问通讯录的权限:

<uses-permission android:name="android.permission.READ_CONTACTS"/>

posted @ 2010-08-25 16:52  陈显  阅读(1359)  评论(0编辑  收藏  举报