PopulateStorageAction


public final class PopulateStorageAction implements BackupDeviceAction


Populates test data inside the application sandbox before a backup.

Reads androidx.test.backup.BackupActionInputKeys.STORAGE_TYPE from the incoming arguments and seeds the specified data into android.content.SharedPreferences, a SQLite database, or raw file storage. See androidx.test.backup.BackupActionInputKeys for the keys each storage type consumes.

Once the data is written, BackupManager.dataChanged is called so the platform knows the app has backup-eligible changes pending.

Summary

Public constructors

Public methods

@NonNull BackupDeviceActionResult

Runs the action payload.

int

The phase of a backup and restore test in which this action runs: PHASE_POPULATE for an action that seeds data before a backup, or PHASE_VERIFY for an action that checks restored data after a restore.

Public constructors

PopulateStorageAction

Added in 1.0.0-alpha03
public PopulateStorageAction()

Public methods

execute

public @NonNull BackupDeviceActionResult execute(@NonNull Context context, @NonNull BackupDeviceActionArgs args)

Runs the action payload.

Implementations should report a recoverable problem, such as a missing argument or a failed assertion, by returning BackupDeviceActionResult.failure rather than by throwing. The host treats a thrown exception as a crash of the action and reports it with a stack trace.

Parameters
@NonNull Context context

application context on the target device

@NonNull BackupDeviceActionArgs args

input arguments passed from the host orchestrator, keyed by BackupActionInputKeys

Returns
@NonNull BackupDeviceActionResult

result returned to the host, keyed by BackupActionOutputKeys

getPhase

public int getPhase()

The phase of a backup and restore test in which this action runs: PHASE_POPULATE for an action that seeds data before a backup, or PHASE_VERIFY for an action that checks restored data after a restore.

The phase only describes the action. This library doesn't read it, so it doesn't change when or how the action runs.