Android-通讯录:添加联系人
2014-08-08 11:24
399 查看
//添加联系人,使用事务 public void testAddContact() { String name[]={"周杰伦","谢霆锋","言承旭","林俊杰","潘玮柏","明道"," 甄子丹"," 周渝民", "罗志祥", "五月天","刘德华"," 麦浚龙"," 成龙"," 苏有朋"," 郭品超"," 阿杜" ,"郑嘉颖"," 吴尊"," 炎亚纶"," 王绍伟"," 唐禹哲"," 巫迪文"," 汪东城" }; for(String ss:name) { //首先插入空值,再得到rawContactsId ,用于下面插值 ContentValues values = new ContentValues (); //insert a null value Uri rawContactUri = getContentResolver().insert(RawContacts.CONTENT_URI,values); long rawContactsId = ContentUris.parseId(rawContactUri); //往刚才的空记录中插入姓名 values.clear(); //A reference to the _ID that this data belongs to values.put(StructuredName.RAW_CONTACT_ID,rawContactsId); //"CONTENT_ITEM_TYPE" MIME type used when storing this in data table values.put(Data.MIMETYPE,StructuredName.CONTENT_ITEM_TYPE); //The name that should be used to display the contact. values.put(StructuredName.DISPLAY_NAME,ss); //insert the real values getContentResolver().insert(Data.CONTENT_URI,values); //插入电话 values.clear(); values.put(Phone.RAW_CONTACT_ID,rawContactsId); //String "Data.MIMETYPE":The MIME type of the item represented by this row //String "CONTENT_ITEM_TYPE": MIME type used when storing this in data table. values.put(Data.MIMETYPE,Phone.CONTENT_ITEM_TYPE); values.put(Phone.NUMBER,"1008611"); getContentResolver().insert(Data.CONTENT_URI,values); } }
相关文章推荐
- Android ContentProvider往通讯录添加联系人
- Android-通讯录:向分组Group添加联系人
- Android向通讯录添加联系人的一般方法
- Android自学之路-- 03:访问通讯录,并向通讯录中添加联系人
- Android ContentProvider(类容提供者)之操作通讯录联系人 添加查询联系人
- Android编程实现通讯录中联系人的读取,查询,添加功能示例
- Android实现批量添加联系人到通讯录
- Android 通讯录添加联系人 自定义电话类型
- android系统通讯录源码--显示联系人添加长按事件监听
- android 向系统通讯录添加一个联系人信息
- Android开发入门之访问通讯录中的联系人和添加联系人
- android通讯录 添加联系人
- Android向通讯录添加联系人的一般方法
- Android向通讯录添加联系人的一般方法
- Android编程实现通讯录中联系人的读取,查询,添加功能示例
- Android向通讯录添加联系人的一般方法
- Android--读取通讯录并添加联系人
- 【Android】从通讯录添加联系人——一个你不知道的细节
- Android批量添加联系人到通讯录
- android 联系人操作: ContentProvider往通讯录添加联系人和获取联系人