Sam,
I think the problem is how you created the contact entry. Try this
method to create contact
replace CallCardProvider object with yours actual parameters. Then try
delete or update this entry using methods above.
Hope it helps.
Ildus
//Create Contact //
public long createContactEntry(CallCardProvider ccp) {
ContentValues values = new ContentValues();
Uri phoneUri = null;
values.put(Contacts.People.NAME, mCtx.getText
(R.string.nameStartWith)+" "+ccp.getName());
//1 = the new contact is added to favorites
//0 = the new contact is not added to favorites
values.put(Contacts.People.STARRED,0);
values.put(People.NOTES, ccp.getPostNumber());
//Add Phone Numbers
Uri uri = this.mCtx.getContentResolver().insert
(Contacts.People.CONTENT_URI, values);
long contactId = Long.parseLong(uri.getLastPathSegment());
Log.i(TAG,"UriPeople="+uri.toString()+" id created="+contactId);
phoneUri = Uri.withAppendedPath(uri,
Contacts.People.Phones.CONTENT_DIRECTORY);
Log.i(TAG, "phoneUri="+phoneUri.toString());
values.clear();
values.put(Contacts.Phones.TYPE,
Phones.TYPE_CUSTOM);//.TYPE_MOBILE);
values.put(Contacts.Phones.LABEL, ccp.getNotes());
values.put(Contacts.Phones.NUMBER,
ccp.getNumber());//.split(",")
[0]);
Uri phone = mCtx.getContentResolver().insert(phoneUri, values);
long phoneId = Long.parseLong(phone.getLastPathSegment());
Log.i(TAG, "Phone created="+phone.toString());
Uri groupMember = Contacts.GroupMembership.CONTENT_URI;
Uri group = Contacts.Groups.CONTENT_URI;
Cursor c = mCtx.getContentResolver().query(group, new String[]
{Groups._ID},
Groups.NAME+"='"+Groups.GROUP_MY_CONTACTS+"'",
null, null);
long groupId = 0;
if(c.getCount()>0 && c.moveToFirst())
groupId = c.getLong(c.getColumnIndex(Groups._ID));
c.close();
if(groupId ==0) {
Log.e(TAG, "groupId=0 Insert to group is skipped");
return phoneId;
}
values.clear();
values.put(Contacts.GroupMembership.PERSON_ID, contactId);
values.put(Contacts.GroupMembership.GROUP_ID, groupId);
groupMember = mCtx.getContentResolver().insert(groupMember,
values);
Log.i(TAG, "groupMemberUri = "+groupMember.toString());
return phoneId;
}
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~----------~----~----~----~------~----~------~--~---