Package-level declarations
Recover
Recover
The recovery process allows you to restore contacts that are marked as deleted. You can learn more about deleted contacts in the manual.
Fetch Deleted Contacts
The first step is to get a list of deleted contacts (ContactItem) by calling:
val contactManager: ContactManager
val recoverManager: RecoverManager = contactManager.recover
lifecycleScope.launch {
recoverManager.getDeletedContacts().collect { deletedContacts ->
// deletedContacts: List<ContactItem>
// Handler it...
}
}Begin Recovering
To recover deleted contacts, you need to call:
val contactManager: ContactManager
val recoverManager: RecoverManager = contactManager.recover
val deletedContacts: List<ContactItems>
val recoverJob: Job = recoverManager.recover(deletedContacts)
// Than you can track backup process
lifecycleScope.launch {
recoverManager.state.collect { backupState ->
when (backupState) {
is RecoverState.NotActive -> {}
is RecoverState.Preparation -> {}
is RecoverState.Processing -> {}
is RecoverState.Succeeded -> {}
is RecoverState.Failed -> {}
}
}
}The parameter ``deletedContacts`` is a list of deleted contacts obtained in the previous step.
The ``recoverManager.state`` flow emits the following state objects from the RestoreState object:
NotActive - rest status;
Preparation - preparation status;
Processing - processing status with progress
`progress: Float`and status of the restore process``step: RecoverStep``variables.The enum RecoverStep has the following values:
``ADDING``- creating contacts on the device. It has a measurable progress: 0..1.``COLLECTING``- collection of local contacts from the device. It has a measurable progress: 0..1.``UPLOADING``- uploading update to backend. The progress is indeterminate = -1.``PROCESSING``- processing update on backend. The progress is indeterminate = -1.Succeeded - successful completion of the backup.
Failed - error state, contains
``throwable: Throwable``.
Types
Defines the step of recover process: adding - creating contacts on the device. It has measurable progress: 0..1. collecting - collection of local contacts from the device. It has measurable progress: 0..1. uploading - uploading update to backend. Progress is indeterminate = -1. processing - processing update on backend. Progress is indeterminate = -1.