I try to add an address on an existing contact:
// insert
operations.Add(ContentProviderOperation.NewInsert(ContactsContract.Data.ContentUri)
.WithValue(ContactsContract.Data.InterfaceConsts.ContactId, contact.Id)
.WithValue(ContactsContract.Data.InterfaceConsts.RawContactId, GetRawContactId(contact.Id))
.WithValue(ContactsContract.Data.InterfaceConsts.Mimetype, ContactsContract.CommonDataKinds.StructuredPostal.ContentItemType)
.WithValue(ContactsContract.CommonDataKinds.StructuredPostal.Pobox, address.PoBox)
.WithValue(ContactsContract.CommonDataKinds.StructuredPostal.Street, address.Street)
.WithValue(ContactsContract.CommonDataKinds.StructuredPostal.City, address.City)
.WithValue(ContactsContract.CommonDataKinds.StructuredPostal.Postcode, address.Postcode)
.WithValue(ContactsContract.CommonDataKinds.StructuredPostal.Country, address.Country)
.WithValue(ContactsContract.CommonDataKinds.CommonColumns.Type, GetAddressContactInfoType(address.InfoType))
.Build());
but all I get is a
Android.Content.OperationApplicationException: insert failed
any suggestions?
thank you very much in advance
finally I found the solution. I had to remove the following line:
.WithValue(ContactsContract.Data.InterfaceConsts.ContactId, contact.Id)