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

Lifecycle phase when this action runs.

Public constructors

PopulateStorageAction

Added in 1.0.0-alpha02
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()

Lifecycle phase when this action runs.