本文介绍了机器人编辑联系人的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
您好我尝试一个电话号码添加到Android 2.1的现有联系人。即时通讯目前使用:
ContentValues值=新ContentValues();
values.put(Phone.RAW_CONTACT_ID,cursor.getColumnIndex(Phone.CONTACT_ID));
串选择= ContactsContract.Contacts.IN_VISIBLE_GROUP +='1';
ContentResolver的CR = getContentResolver();
光标光标= cr.query(ContactsContract.Contacts.CONTENT_URI,空,选择,空,ContactsContract.Contacts.DISPLAY_NAME +分页中局部ASC);
如果(cursor.getCount()大于0){
cursor.moveToPosition(oldcontactid);
使用ContactID = cursor.getString(cursor.getColumnIndex(ContactsContract.Contacts._ID));
values.put(Phone.RAW_CONTACT_ID,cursor.getColumnIndex(Phone.CONTACT_ID));
如果(Integer.parseInt(cursor.getString(cursor.getColumnIndex(ContactsContract.Contacts.HAS_PHONE_NUMBER))) > 0){
光标pCur = cr.query(ContactsContract.CommonDataKinds.Phone.CONTENT_URI,null,ContactsContract.CommonDataKinds.Phone.CONTACT_ID +=?,新的String [] {}的ContactID,NULL);
而(pCur.moveToNext()){
values.put(Phone.NUMBER,pCur.getString(pCur.getColumnIndex(ContactsContract.CommonDataKinds.Phone.NUMBER)));
values.put(Phone.TYPE,Phone.TYPE_MOBILE);
}
pCur.close();
}
}
。URI URI = getContentResolver()插入(Phone.CONTENT_URI,价值观);
但我得到一个错误:
java.lang.UnsupportedOperationException:未知网址:内容://com.android.contacts/data/phones
如何将我能够解决这一问题?
感谢您的帮助,ng93
解决方案
检查这两个链接它会帮助:)
hi im trying to add a phone number to an existing contact on android 2.1. Im currently using:
ContentValues values = new ContentValues();
values.put(Phone.RAW_CONTACT_ID,cursor.getColumnIndex(Phone.CONTACT_ID));
String selection = ContactsContract.Contacts.IN_VISIBLE_GROUP + " = '1'";
ContentResolver cr = getContentResolver();
Cursor cursor = cr.query(ContactsContract.Contacts.CONTENT_URI,null, selection, null,ContactsContract.Contacts.DISPLAY_NAME+" COLLATE LOCALIZED ASC");
if (cursor.getCount() > 0) {
cursor.moveToPosition(oldcontactid);
contactid = cursor.getString(cursor.getColumnIndex(ContactsContract.Contacts._ID));
values.put(Phone.RAW_CONTACT_ID,cursor.getColumnIndex(Phone.CONTACT_ID));
if (Integer.parseInt(cursor.getString(cursor.getColumnIndex(ContactsContract.Contacts.HAS_PHONE_NUMBER))) > 0) {
Cursor pCur = cr.query(ContactsContract.CommonDataKinds.Phone.CONTENT_URI,null,ContactsContract.CommonDataKinds.Phone.CONTACT_ID +" = ?",new String[]{contactid}, null);
while (pCur.moveToNext()) {
values.put(Phone.NUMBER,pCur.getString(pCur.getColumnIndex(ContactsContract.CommonDataKinds.Phone.NUMBER)));
values.put(Phone.TYPE, Phone.TYPE_MOBILE);
}
pCur.close();
}
}
Uri uri = getContentResolver().insert(Phone.CONTENT_URI, values);
but i get an error:
java.lang.UnsupportedOperationException: Unknown uri: content://com.android.contacts/data/phones
how would i be able to fix this?
thanks for any help,ng93
解决方案
check this both link it will help :)
这篇关于机器人编辑联系人的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!