小菜毛毛技術分享

          與大家共同成長

            BlogJava :: 首頁 :: 聯系 :: 聚合  :: 管理
            164 Posts :: 141 Stories :: 94 Comments :: 0 Trackbacks

          常用鏈接

          留言簿(15)

          我參與的團隊

          搜索

          •  

          最新評論

          閱讀排行榜

          評論排行榜

          1. String[] projection = new String[] {  
          2. People._ID,  
          3. People.NAME,  
          4. People.NUMBER,  
          5. };  
          6.   
          7. // Get the base URI for People table in Contacts content provider.  
          8. // which is: content://contacts/people/  
          9. Uri contactUri = People.CONTENT_URI;  
          10.   
          11. // Best way to retrieve a query; returns a managed query.  
          12. Cursor peopleCursor = managedQuery (contactUri,  
          13. projection, //Which columns to return.  
          14. null, // WHERE clause--we won't specify.  
          15. null, // Selection Args??  
          16. People.DEFAULT_SORT_ORDER); // Order-by name  
          17.   
          18. // go to the beginning of the list  
          19. peopleCursor.moveToFirst();  
          20.   
          21.   
          22. // So, here we have a contact. We need to get the contact ID (_id) then  
          23. // build the Uri to get the phones section of that user's record  
          24. // which is a subdirectory of a contact record  
          25.   
          26. long personId = peopleCursor.getLong(peopleCursor.getColumnIndex("_id"));  
          27.   
          28. Uri personUri = ContentUris.withAppendedId(contactUri, personId );  
          29.   
          30. // So now the URL looks like: content://contacts/people/_id(where the actual id of the record is here)  
          31. Uri phoneUri=  
          32. Uri.withAppendedPath(personUri, Contacts.People.Phones.CONTENT_DIRECTORY);  
          33.   
          34. // Now the URL looks like: content://contacts/people/_id/phones (where phones is literally "phones")  
          35.   
          36. // Now get all the phone numbers for this contact  
          37. Cursor phonesCursor = managedQuery(phoneUri,  
          38. null,  
          39. null,  
          40. null,  
          41. Phones.DEFAULT_SORT_ORDER);  
          42.   
          43. // We now have a cursor for all the phone numbers for that User ID  
          44. // go to the beginning of the phone list.  
          45. phonesCursor.moveToFirst();   
          posted on 2010-12-17 17:45 小菜毛毛 閱讀(1059) 評論(0)  編輯  收藏 所屬分類: andriod
          主站蜘蛛池模板: 沙湾县| 古浪县| 皋兰县| 和平县| 金山区| 北海市| 长武县| 师宗县| 长丰县| 行唐县| 冀州市| 拜城县| 桐庐县| 阳谷县| 洛隆县| 乌什县| 六枝特区| 磐石市| 湖州市| 浦东新区| 东辽县| 健康| 西安市| 哈巴河县| 富平县| 社旗县| 肥东县| 大化| 武隆县| 胶州市| 弋阳县| 土默特左旗| 泗水县| 太保市| 陆河县| 连山| 宝应县| 青龙| 潜山县| 炎陵县| 平凉市|