阅读更多

下面是论坛上有人写的关于获取Contact Number的code,非常详细,供参考。

String[] projection = new String[] {People._ID,People.NAME,People.NUMBER,};// Get the base URI for People table in Contacts content provider.// which is: content://contacts/people/Uri contactUri = People.CONTENT_URI;// Best way to retrieve a query; returns a managed query.Cursor peopleCursor = managedQuery (contactUri,projection, //Which columns to return.null, // WHERE clause--we won't specify.null, // Selection Args??People.DEFAULT_SORT_ORDER); // Order-by name// go to the beginning of the listpeopleCursor.moveToFirst();// So, here we have a contact. We need to get the contact ID (_id) then// build the Uri to get the phones section of that user's record// which is a subdirectory of a contact recordlong personId = peopleCursor.getLong(peopleCursor.getColumnIndex("_id"));Uri personUri = ContentUris.withAppendedId(contactUri, personId );// So now the URL looks like: content://contacts/people/_id(where the actual id of the record is here)Uri phoneUri=Uri.withAppendedPath(personUri, Contacts.People.Phones.CONTENT_DIRECTORY);// Now the URL looks like: content://contacts/people/_id/phones (where phones is literally "phones")// Now get all the phone numbers for this contactCursor phonesCursor = managedQuery(phoneUri,null,null,null,Phones.DEFAULT_SORT_ORDER);// We now have a cursor for all the phone numbers for that User ID// go to the beginning of the phone list.phonesCursor.moveToFirst(); 
 

 

更多相关文章

  1. Android(安卓)AVD之Socket Connect Time Out
  2. Android(安卓)解决 Toolbar 的 Menu 图标无法显示
  3. 自定义TabHost
  4. 搜集的android资源
  5. 年终了,说说今年手机软件市场,说说明年对Android Market的期望
  6. android实现discuz论坛的登录
  7. android 优秀博客的保存
  8. Android ViewPager多页面滑动切换以及底部滑动导航

随机推荐

  1. Android(安卓)studio使用Lottie- 让Andro
  2. Android的标题栏
  3. Android(安卓)编译环境配置搭建(Ubuntu 1
  4. android shape 使用小结
  5. android 禁止EditText自动获得焦点
  6. android Eclipse开发问题汇总
  7. Android(安卓)Pull解析
  8. Android(安卓)SDK下载地址
  9. android clipChildren与clipToPadding
  10. Android下setLatestEventInfo警告、Handl