Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>Each field (email, name, adreess) has its own mime type, which you should use in order to update the field.</p> <p>We will work with Data table, where each Data.RAW_CONTACT_ID represents a detail about some contact.</p> <p>So, we need to find the Data.RAW_CONTACT_ID where the id is the id of the contact you want to edit.</p> <p>I hope this code should be helpful to you.</p> <pre><code> String selectPhone = Data.RAW_CONTACT_ID + "=? AND " + Data.MIMETYPE + "='" + ContactsContract.CommonDataKinds.StructuredPostal.CONTENT_ITEM_TYPE + "'" ; String[] phoneArgs = new String[]{String.valueOf(rawContactId)}; ops.add(ContentProviderOperation.newUpdate(Data.CONTENT_URI) .withSelection(selectPhone, phoneArgs) .withValue(ContactsContract.CommonDataKinds.StructuredPostal.TYPE, ContactsContract.CommonDataKinds.StructuredPostal.TYPE_WORK) .withValue(ContactsContract.CommonDataKinds.StructuredPostal.STREET, STREET) .withValue(ContactsContract.CommonDataKinds.StructuredPostal.CITY, CITY) .withValue(ContactsContract.CommonDataKinds.StructuredPostal.REGION, REGION) .withValue(ContactsContract.CommonDataKinds.StructuredPostal.POSTCODE, POSTCODE) .withValue(ContactsContract.CommonDataKinds.StructuredPostal.COUNTRY, POSTCODE) .build()); this.context.getContentResolver().applyBatch(ContactsContract.AUTHORITY, ops); </code></pre> <p>If a new contact has been created, but without address, and now you want to add an address to that contcat. In this case use the same query as above, but just change newUpdate to newInsert, since such row isn't exist yet.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload