Android Kills Direct WRITE_CONTACTS: Migration Guide to Intent-Based Contact Editing
Yesterday, Android announced its plan to adjust contacts write permissions. For apps targeting the next version of Android in 2027, requesting WRITE_CONTACTS alone will no longer allow direct writes to the contacts database.
Saving a business card or adding a phone number to an existing contact, operations that are actively triggered by the user, can be delegated to the contact editor page. Apps that need continuous background sync should evaluate the new special access permission MANAGE_CONTACTS.
Effective Timeline
This adjustment is rolled out in two phases; it should not be interpreted as WRITE_CONTACTS being fully invalidated on Android 17.
| Time | Change |
|---|---|
| 2026, Android 17 QPR2 | Provide MANAGE_CONTACTS special access permission |
| 2027, next Android version | Tighten direct write permissions for apps targeting that version and above; unify contact Intent behavior |
| 2027, no earlier than that version's release | Advance Play Console declarations and policy compliance requirements |
Apps targeting older platform versions retain their original write behavior. On new systems, a standardized contact editing experience will be provided to apps with different target SDKs. The device system version and the app's target SDK need to be judged separately.
Saving a Business Card
Assume an app scans a business card and obtains a name, phone number, and email. The old implementation might first request WRITE_CONTACTS, then create a raw contact via ContentResolver, and then insert specific fields into the Data table.
This approach requires maintaining the contacts table structure and handling write permissions. By switching to ACTION_INSERT, the app passes the recognition results to the editor page, the user reviews and saves them. The following example is based on the Contacts developer guide and is called in an Activity:
import android.app.Activity
import android.content.Intent
import android.provider.ContactsContract
fun Activity.saveBusinessCard(
name: String,
phone: String,
email: String,
) {
val editor = Intent(Intent.ACTION_INSERT).apply {
type = ContactsContract.RawContacts.CONTENT_TYPE
putExtra(ContactsContract.Intents.Insert.NAME, name)
putExtra(ContactsContract.Intents.Insert.PHONE, phone)
putExtra(ContactsContract.Intents.Insert.EMAIL, email)
}
// This only opens a pre-filled form; the contact is confirmed and saved by the user.
startActivity(editor)
}
ACTION_INSERT expresses creating a new contact, the MIME type is used to match the contact creation entry, and Extras are used to pre-fill fields. This call does not require the app to request contact write permission, nor does it require the app to organize the batch operations for creating a raw contact.
The interaction here changes: originally it might be a direct write after clicking a button, but now there will be a confirmation page. startActivity() returning only means the call has been dispatched; you cannot immediately show "Contact saved successfully"; the user might change the number or cancel.
Intents work on older Android versions too, handled by the device's contacts app. New versions will unify editing behavior, but older devices still require verification that the specific contacts app correctly preserves the passed fields.
Adding a Phone Number
Scan results don't always need to create a new contact. For example, if a colleague changes work numbers and the user wants to add the new number to an existing contact, but the app doesn't know which record to modify.
In this case, use ACTION_INSERT_OR_EDIT. It allows the user to select an existing contact or create a new one; the passed phone number will be carried to the subsequent editing screen. The following is also called in an Activity:
fun Activity.attachPhone(phone: String) {
val editor = Intent(Intent.ACTION_INSERT_OR_EDIT)
editor.type = ContactsContract.Contacts.CONTENT_ITEM_TYPE
editor.putExtra(ContactsContract.Intents.Insert.PHONE, phone)
// Do not set the data URI; let the user choose the target contact.
startActivity(editor)
}
Note that here Contacts.CONTENT_ITEM_TYPE is used, and no data URI is set. When the app already holds a valid URI for the target contact, use ACTION_EDIT:
import android.net.Uri
fun Activity.attachPhoneToContact(contactUri: Uri, phone: String) {
val editor = Intent(Intent.ACTION_EDIT).apply {
data = contactUri
putExtra(ContactsContract.Intents.Insert.PHONE, phone)
}
startActivity(editor)
}
Here contactUri points to a contact record and cannot be replaced with the URI corresponding to rawContactId. Contacts is the aggregated contact, while RawContacts is the raw record under a specific account; they are not on the same level of data.
"Save this business card" corresponds to creating a new contact; "add this number to the address book" corresponds to letting the user choose; modifying after locating Zhang San corresponds to editing. Once the business entry point is determined, the Intent choice is relatively direct.
Accounts and Avatars
On multi-account devices, contacts might be saved to different accounts. ContactsContract.Intents.Insert.EXTRA_ACCOUNT can carry an android.accounts.Account to hint at the save location. This field has existed since API 23; this adjustment will unify its support behavior on new systems; do not treat it as a new API.
The new field for avatars is ContactsContract.Intents.Insert.EXTRA_PHOTO_URI, planned to be provided with the next Android version in 2027. The following is a supplementary snippet for the new API, placed on the Intent for creating a new contact; it requires using an SDK that includes this constant, and old SDK projects cannot directly copy it:
import android.content.ClipData
// photoUri is a content URI that the app has permission to grant externally.
editor.apply {
putExtra(
ContactsContract.Intents.Insert.EXTRA_PHOTO_URI,
photoUri,
)
// The Extra passes the avatar purpose; ClipData and flags grant read permission to the receiver.
clipData = ClipData.newRawUri("contact-photo", photoUri)
addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION)
}
The avatar URI and read permission are two separate things. Putting the URI into the Extra does not mean the receiver can read the image; after the URI is placed into ClipData, the read grant flag covers it. If the avatar is a file in the app's private directory, it needs to be exposed as a grantable content URI via FileProvider first.
Do not delete the avatar file immediately after launching the editor page. The contact editor page might not have finished reading it; deleting the file prematurely will cause image loading to fail. On old systems, relying on this new Extra to guarantee avatar pre-fill is not guaranteed.
Background Sync Permission
Enterprise contacts two-way sync, contacts bulk backup/restore, cannot have users open the editor page and confirm each entry. This kind of business is when MANAGE_CONTACTS should be evaluated, in combination with Play's admission requirements and declarations.
It is a special app access permission; users need to go to system settings to enable it, and it cannot be requested via requestPermissions() with a standard runtime permission dialog. The granted scope includes read, add, update, and delete; apps that already have this permission do not need to additionally request READ_CONTACTS.
Simply wanting to keep a custom contact editing page is not by itself a valid reason for requesting it. Additionally, contact Intents have no delete entry; ACTION_EDIT cannot be used to impersonate a delete operation.
When migrating, also look at the data types passed. The new editor supports standard ContactsContract.CommonDataKinds types; custom MIME rows will be ignored. Implementations that previously injected entries like "call via this app" into the address book need to be evaluated separately with People Directory, and cannot just stuff a whole batch of Data rows into an Intent.
Auditing Old Code
First locate permission declarations and direct write entry points in business code:
rg -n \
'WRITE_CONTACTS|RawContacts\.CONTENT_URI|Data\.CONTENT_URI|applyBatch' \
app/src
Search results are only candidate locations; Data.CONTENT_URI might also be used for queries. Confirm each spot whether it actually calls insert, update, delete, or applyBatch, and distinguish between user-initiated saves and background sync, to avoid treating read-only queries as write migrations.
After changing user-initiated save entry points to Intents, check whether cancel actions incorrectly report success, whether existing contacts keep original fields when adding numbers, and whether avatars can be read by the editor. After removing all paths that depend on write permission, delete WRITE_CONTACTS from the Manifest.
If there are compatibility issues on old devices that genuinely rely on direct writes, consider using maxSdkVersion to limit the old permission. The specific boundary should correspond to the actual compatibility implementation; do not directly use Android 17's API level as the boundary for the next version's write restriction.
Finally
Use ACTION_INSERT for new contacts, ACTION_INSERT_OR_EDIT when the target is unknown, and ACTION_EDIT when the contact URI is known. These interfaces are usable now.
Is your app ready for adaptation? Of course not...