Android获取Contact Number的例子(2.0系统以前的获取方式)
  1. String[]projection=newString[]{
  2. People._ID,
  3. People.NAME,
  4. People.NUMBER,
  5. };
  6. //GetthebaseURIforPeopletableinContactscontentprovider.
  7. //whichis:content://contacts/people/
  8. UricontactUri=People.CONTENT_URI;
  9. //Bestwaytoretrieveaquery;returnsamanagedquery.
  10. CursorpeopleCursor=managedQuery(contactUri,
  11. projection,//Whichcolumnstoreturn.
  12. null,//WHEREclause--wewon'tspecify.
  13. null,//SelectionArgs??
  14. People.DEFAULT_SORT_ORDER);//Order-byname
  15. //gotothebeginningofthelist
  16. peopleCursor.moveToFirst();
  17. //So,herewehaveacontact.WeneedtogetthecontactID(_id)then
  18. //buildtheUritogetthephonessectionofthatuser'srecord
  19. //whichisasubdirectoryofacontactrecord
  20. longpersonId=peopleCursor.getLong(peopleCursor.getColumnIndex("_id"));
  21. UripersonUri=ContentUris.withAppendedId(contactUri,personId);
  22. //SonowtheURLlookslike:content://contacts/people/_id(wheretheactualidoftherecordishere)
  23. UriphoneUri=
  24. Uri.withAppendedPath(personUri,Contacts.People.Phones.CONTENT_DIRECTORY);
  25. //NowtheURLlookslike:content://contacts/people/_id/phones(wherephonesisliterally"phones")
  26. //Nowgetallthephonenumbersforthiscontact
  27. CursorphonesCursor=managedQuery(phoneUri,
  28. null,
  29. null,
  30. null,
  31. Phones.DEFAULT_SORT_ORDER);
  32. //WenowhaveacursorforallthephonenumbersforthatUserID
  33. //gotothebeginningofthephonelist.
  34. phonesCursor.moveToFirst();

更多相关文章

  1. GitHub 标星 2.5K+!教你通过玩游戏的方式学习 VIM!
  2. Nginx系列教程(六)| 手把手教你搭建 LNMP 架构并部署天空网络电影
  3. 基于Android的WebService开发例子
  4. MTK Android(安卓)平台开发之旅
  5. android 输入法框架简介
  6. Learning Android(安卓)Studio to build a app from scratch
  7. Android(安卓)Framework 分析
  8. Android(安卓)按钮响应点击事件的三种实现方式
  9. Linux 内核启动挂载android根文件系统过程分析

随机推荐

  1. 数据工程师面试必备——Python与数据库的
  2. 用python制作动态图表看全球疫情变化趋势
  3. 2020最值得学习的12款python-web开发框架
  4. 疫情数据哪里找,看这篇就够了
  5. Jar 文件(学习 Java 编程语言 037)
  6. 技术解析:如何获取全球疫情历史数据并处理
  7. 技术解析:如何用pyecharts绘制时间轮播图
  8. 武大樱花又盛开,用python画一棵樱花树
  9. python数据分析万字干货!一个数据集全方位
  10. 【决战西二旗】|Redis面试热点之底层实现