Skip to content

Latest commit

 

History

History
67 lines (48 loc) · 2.25 KB

delete-custom-data.md

File metadata and controls

67 lines (48 loc) · 2.25 KB

Delete custom data

This library provides several APIs that supports deleting custom data.

  1. DataDelete
  2. Delete
  3. ProfileDelete
  4. Update
  5. ProfileUpdate

To help illustrate how custom data integrates with these update APIs, we'll use the HandleName and Gender custom data.

ℹ️ For more info about custom data, read Integrate custom data.

Deleting custom data via Contacts/RawContacts

Custom data, just like regular data kinds, are attached to a RawContact. They follow the same rules as regular data kinds.

ℹ️ or more info, read about API Entities.

For example, you are able to delete existing handle names and the gender of an existing RawContact,

mutableRawContact.removeHandleName(contactsApi, handleName)
mutableRawContact.setGender(contactsApi, null)

There are also extensions that allow you to delete custom data of an existing RawContact via a Contact, which can be made up of one or more RawContacts,

mutableContact.removeHandleName(contactsApi, handleName)
mutableContact.setGender(contactsApi, null)

Once you have removed custom data, you can perform the update operation on the RawContact to commit your changes into the database using Update or ProfileUpdate.

You may also delete an entire Contact or RawContact using Delete or ProfileDelete in order delete all associated data.

Deleting set of custom data directly

All custom data are compatible with the DataDelete API, which allows you to delete sets of existing regular and custom data kinds.

For example, to delete a set of HandleNames and Genders,

val handleNames: List<MutableHandleName>
val genders: List<MutableGender>

val deleteResult = Contacts(this)
   .data()
   .delete()
   .data(handleNames + genders)
   .commit()

For more info, read Delete existing sets of data.