java - Android contact data fields can edit but not create -
i use code update contact's address, works contacts have existing address. if contact address field empty, update() method returns 0 , contact data not updated. how add address existing contact?
//str_id contact's id //input string representing address contentvalues cv = new contentvalues(); string[] params = new string[] { str_id, contactscontract.commondatakinds.structuredpostal.content_item_type }; cv.put(contactscontract.commondatakinds.structuredpostal.formatted_address, input); getcontentresolver().update(contactscontract.data.content_uri, cv, contactscontract.data.contact_id + " = ? , " + contactscontract.data.mimetype + " = ?", params);
i have tried equivalent logic contentprovideroperation, same result. previous example, can update existing address cannot create address.
arraylist<contentprovideroperation> ops = new arraylist<contentprovideroperation>(); ops.add(contentprovideroperation.newinsert(contactscontract.data.content_uri) .withvaluebackreference(contactscontract.data.raw_contact_id, id) .withvalue(contactscontract.data.mimetype, contactscontract.commondatakinds.structuredpostal.content_item_type) .withvalue(contactscontract.commondatakinds.structuredpostal.formatted_address, input) .build());
you need check whether adress exist or not before updating address, if address exist above code work fine doing update..
while doing insert address, doing a child insert" see here, explanation of contentprovideroperation relates issue closely..
Comments
Post a Comment