android中如何取得用户手机的常用联系人(即收藏夹的联系人) (转载) http://blog.csdn.net/qiaoning13256/article/details/6889315
1
2 /**
3 *获得收藏夹的联系人
4 */
5 private void getKeepedContacts(){
6 Cursorcur = getContentResolver().query(
7 ContactsContract.Contacts.CONTENT_URI, null ,ContactsContract.Contacts.STARRED + " =1 " , null , null );
8 startManagingCursor(cur);
9 int num = cur.getCount();
10 System.out.println(num + "" );
11 int count = 0 ;
12 while (cur.moveToNext()){
13 count ++ ;
14
15 long id = cur.getLong(cur.getColumnIndex( " _id " ));
16 Cursorpcur = getContentResolver().query(
17 ContactsContract.CommonDataKinds.Phone.CONTENT_URI,
18 null ,
19 ContactsContract.CommonDataKinds.Phone.CONTACT_ID + " = "
20 + Long.toString(id), null , null );
21
22 // 处理多个号码的情况
23 StringphoneNumbers = "" ;
24 while (pcur.moveToNext()){
25 StringstrPhoneNumber = pcur
26 .getString(pcur
27 .getColumnIndex(ContactsContract.CommonDataKinds.Phone.NUMBER));
28 phoneNumbers += strPhoneNumber + " : " ;
29 }
30 phoneNumbers += " \n " ;
31 pcur.close();
32 Stringname = cur.getString(cur.getColumnIndex( " display_name " ));
33 contactNameList.add(name);
34 contactNumList.add(phoneNumbers);
35 }
36 cur.close();
37 }

更多相关文章

  1. Android(安卓)---模拟手机发送短信
  2. android调用系统发短信传递电话号码和短信内容
  3. Android(安卓)MMS/SMS(二)
  4. ContactsContract获取联系人信息
  5. ContactsProvider2
  6. 11 Weeks of Android: 联系人与身份
  7. Android实现短信自动回复,挂电话
  8. EditTextView 带空格分隔的输入(电话号码,银行卡)
  9. Android内容提供者之读取联系人信息

随机推荐

  1. android获取内置和外置SD卡路径
  2. Android 自动化测试—robotium(五)Spinner
  3. Android Linux Socket 数据传输错误
  4. Android 加快编译时间
  5. android开发 使用uses-sdk 导致布局不一
  6. android dm-verity 功能
  7. Android(安卓)菜单Menu学习
  8. Android(安卓)Systrace使用介绍
  9. VideoView控件可以手动改变大小
  10. android Hid 实现注意事项