如何调用系统自带的联系人活动
SDK是2.2的,权限都加了调用系统修改联系人的时候
Intent i;
i = new Intent(Intent.ACTION_EDIT);
i.setData(Uri.parse("content://contacts/people/1"));
startActivity(i);
11-25 01:43:09.745: ERROR/AndroidRuntime(1456): Caused by: android.database.sqlite.SQLiteException: no such column: raw_contact_id: , while compiling: SELECT data_version, contact_id, version, data12, data11, data10, mimetype, res_package, _id, data15, data14, data13, name_verified, is_restricted, is_super_primary, data_sync1, dirty, data_sync3, data_sync2, data_sync4, account_type, data1, sync4, sync3, data4, sync2, data5, sync1, data2, data3, data8, data9, deleted, group_sourceid, data6, data7, account_name, data_id, starred, sourceid, is_primary FROM contact_entities_view WHERE (1) AND (raw_contact_id=12)
有人碰到过这种情况吗?
还有,能不能调用系统删除联系人呢?谢谢各位了
--------------------编程问答-------------------- http://www.eoeandroid.com/thread-24201-1-1.html
上面的异常你查询的数据跟联系人表不匹配 --------------------编程问答-------------------- 另外确保你的uri正确 --------------------编程问答-------------------- 能够告知 正确的URI应该如何设置
我现在是显示出系统的联系人列表,然后点击之后返回到本身的Activity中,再通过获取到的URI参数修改联系人,应该怎么改? --------------------编程问答-------------------- 没有人回了,顶起来 --------------------编程问答-------------------- http://blog.csdn.net/xuxinyl/archive/2010/11/24/6032870.aspx
这是刚看到的一个博客 --------------------编程问答-------------------- 呃,我不是要读取联系人,是要修改联系人的 --------------------编程问答--------------------
修改是不是用update()啊?insert应该是添加吧? --------------------编程问答-------------------- 说的很明确,no such column
1是什么?people后面应该是联系人的id,估计是没有1这个id,可以先通过获取所有联系人信息,然后查看一下对应的contact_id,然后再根据指定人的id调用你的方法 --------------------编程问答-------------------- 你可以自己从他数据库读取,自己建立个存储结构,然后再删、编辑、增加都可以的。
Cursor cursor=getContentResolver().query(ContactsContract.Contacts.CONTENT_URI, null, null, null, null);
startManagingCursor(cursor);
ContentResolver cr = getContentResolver();
while (cursor.moveToNext())
{ String string = null;
// 取得联系人名字
int nameFieldColumnIndex = cursor.getColumnIndex(PhoneLookup.DISPLAY_NAME);
String name = cursor.getString(nameFieldColumnIndex);
//System.out.println(name);
// 取得联系人ID
String contactId = cursor.getString(cursor.getColumnIndex(ContactsContract.Contacts._ID));
Cursor phone = cr.query(ContactsContract.CommonDataKinds.Phone.CONTENT_URI, null,
ContactsContract.CommonDataKinds.Phone.CONTACT_ID + " = "
+ contactId +" and "+ ContactsContract.CommonDataKinds.Phone.TYPE + " =2 "
, null, null);
int count=0;
count=phone.getCount();
if(count==0)
{
continue;
}
else
{
// 取得电话号码(可能存在多个号码)
phone.moveToNext();
String phone_id=phone.getString(phone.getColumnIndex
(ContactsContract.CommonDataKinds.Phone.TYPE));
String strPhoneNumber = phone.getString(phone.getColumnIndex
(ContactsContract.CommonDataKinds.Phone.NUMBER));
string = (name+":" + strPhoneNumber);
// System.out.println(phone_id + "------------" + string);
HashMap<String, Object> map=new HashMap<String, Object>();
map.put("name", name);
map.put("phonenum", strPhoneNumber);
listitem.add(map);
}
phone.close();
--------------------编程问答-------------------- 异常你查询的数据跟联系人表不匹配 --------------------编程问答-------------------- http://www.eoeandroid.com/thread-37271-1-1.html——这个很有用!^_^
补充:移动开发 , Android