我用这样的方法添加联系人姓名
ContentResolver contentResolver = a.getContentResolver(); ContentValues values = new ContentValues();
// 添加姓名 values.put(Contacts.People.NAME,name); // 映射关系:1 = 新的联系方式加入 favorites0 = 新的联系方式不是加入 favorites values.put(Contacts.People.STARRED,0); Uri uri = Contacts.People.createPersonInMyContactsGroup(contentResolver,values);
//contentResolver.insert(uri,values);
用这样的方法读取联系人姓名
String[] phoneProjection = new String[] {
Contacts.Phones.PERSON_ID, Contacts.Phones.NAME }; Cursor phoneCursor = a.getContentResolver().query(
Contacts.Phones.CONTENT_URI, phoneProjection, null, null, null);
if (phoneCursor.moveToFirst()) {
// get the results
do {
String id = phoneCursor.getString(phoneCursor
.getColumnIndex(Contacts.Phones.PERSON_ID));
String name = phoneCursor.getString(phoneCursor
.getColumnIndex(Contacts.Phones.NAME));
} while (phoneCursor.moveToNext());
}
可是执行之后能够在手机上通讯录中看到添加的联系人姓名(没有添加手机号码),但是读取的时候读取不到,哪位大哥指导一下。
ContentResolver contentResolver = a.getContentResolver(); ContentValues values = new ContentValues();
// 添加姓名 values.put(Contacts.People.NAME,name); // 映射关系:1 = 新的联系方式加入 favorites0 = 新的联系方式不是加入 favorites values.put(Contacts.People.STARRED,0); Uri uri = Contacts.People.createPersonInMyContactsGroup(contentResolver,values);
//contentResolver.insert(uri,values);
用这样的方法读取联系人姓名
String[] phoneProjection = new String[] {
Contacts.Phones.PERSON_ID, Contacts.Phones.NAME }; Cursor phoneCursor = a.getContentResolver().query(
Contacts.Phones.CONTENT_URI, phoneProjection, null, null, null);
if (phoneCursor.moveToFirst()) {
// get the results
do {
String id = phoneCursor.getString(phoneCursor
.getColumnIndex(Contacts.Phones.PERSON_ID));
String name = phoneCursor.getString(phoneCursor
.getColumnIndex(Contacts.Phones.NAME));
} while (phoneCursor.moveToNext());
}
可是执行之后能够在手机上通讯录中看到添加的联系人姓名(没有添加手机号码),但是读取的时候读取不到,哪位大哥指导一下。
解决方案 »
- 把应用push到/system/app下面后,加载.so库的问题
- Android如何能让一个页面平分成两块
- ExpandableListView如何能立即实时显示出新的赋值?
- 目前为止google一共发布了多少次android 安全漏洞补丁?多谢了
- android里service怎么会是在主线程里呢?
- Android ExpandableListView中嵌套Gridview
- 用什么组件来显示数据库中的多条纪录?
- 安卓(Android)应用与远程PC机Oracal数据库之间的互相连接
- 请教:如微信公共平台新闻信息这样的样式框如何处理
- NotificationCompat 使用不了
- TextView失去焦点
- hashmap报错
把这个注释放开就行了啊