Skip to main content

Deleted Contacts

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 disposable = CompositeDisposable()val deletedContacts = listOf<ContactItem>()
disposable += ContactManager.recoverProcessor.getDeletedContacts()    .observeOn(AndroidSchedulers.mainThread())    .subscribeBy(        onSuccess = {            deletedContacts = it        },        onError = {            Log.e(TAG, "getContacts> error:", it)        }    )

Begin Recovering#

To recover deleted contacts, you need to call:

ContactManager.recoverProcessor.recover(deletedContacts)

The parameter deletedContacts is a list of deleted contacts obtained in the previous step.

To cancel recover, you need to call:

ContactManager.recoverProcessor.cancelRecover()

To track the status of a recover, you can subscribe to an observable by calling getRecoverStateObservable:

val disposable = CompositeDisposable()
disposable += ContactManager.recoverProcessor.getRecoverStateObservable()    .observeOn(AndroidSchedulers.mainThread())    .subscribe { recoverState ->        when (recoverState) {            is RecoverProcessor.RecoverState.None -> {}            is RecoverProcessor.RecoverState.Processing -> {}            is RecoverProcessor.RecoverState.Succeeded -> {}            is RecoverProcessor.RecoverState.Failed -> {}        }    }

The getRecoverStateObservable method emits the following state objects from the RestoreProcessor.RestoreState object:

  • None - rest status;
  • Processing - processing status with progress progress: Float and status of the restore process recoverStep: 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.