How do I delete the device owner Contact profile?

Android Contacts API Library written in Kotlin with Java interoperability. No more ContentProviders and cursors. Say goodbye to ContactsContract. Build your own contacts app!

How do I delete the device owner Contact profile?

This library provides the ProfileDelete API, which allows you to delete the device owner Profile Contact or only some of its constituent RawContacts.

Note that there can be only one device owner Contact, which is either set (not null) or not yet set (null). However, like other regular Contacts, the Profile Contact may have one or more RawContacts.

An instance of the ProfileDelete API is obtained by,

val delete = Contacts(context).profile().delete()

If you want to delete non-Profile Contacts, read How do I delete Contacts/RawContacts?

A basic delete

To delete a the profile Contact (if it exist) and all of its RawContacts,

val deleteResult = delete

If you want to delete a set of RawContacts belonging to the profile Contact,

val deleteResult = delete

Note that the profile Contact is deleted automatically when all constituent RawContacts are deleted.

Executing the delete

To execute the delete,


If you want to delete all given RawContacts in a single atomic transaction,


The call to commitInOneTransaction will only succeed if ALL given RawContacts are successfully deleted. If one delete fails, the entire operation will fail and everything will be reverted prior to the delete operation. In contrast, commit allows for some deletes to succeed and some to fail. This really only applies to when only rawContacts are specified.

Performing the delete and result processing asynchronously

Deletes are executed when the commit function is invoked. The work is done in the same thread as the call-site. This may result in a choppy UI.

To perform the work in a different thread, use the Kotlin coroutine extensions provided in the async module. For more info, read How do I use the async module to simplify executing work outside of the UI thread using coroutines?

You may, of course, use other multi-threading libraries or just do it yourself =)

Extensions for Kotlin Flow and RxJava are also in the v1 roadmap.

Performing the delete with permission

Deletes require the android.permission.WRITE_CONTACTS permissions. If not granted, the delete will do nothing and return a failed result.

For API 22 and below, the permission “android.permission.WRITE_PROFILE” is also required but only at the manifest level. Prior to API 23 (Marshmallow), permissions needed to be granted prior to installation instead of at runtime.

To perform the delete with permission, use the extensions provided in the permissions module. For more info, read How do I use the permissions module to simplify permission handling using coroutines?

You may, of course, use other permission handling libraries or just do it yourself =)

Custom data support

The ProfileDelete API supports custom data. For more info, read How do I use delete APIs to delete custom data?