PopulateStorageAction


class PopulateStorageAction : 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 functions

open BackupDeviceActionResult

Runs the action payload.

Public properties

open Int

Lifecycle phase when this action runs.

Public constructors

PopulateStorageAction

Added in 1.0.0-alpha02
PopulateStorageAction()

Public functions

execute

open fun execute(context: Context, args: BackupDeviceActionArgs): BackupDeviceActionResult

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
context: Context

application context on the target device

args: BackupDeviceActionArgs

input arguments passed from the host orchestrator, keyed by BackupActionInputKeys

Returns
BackupDeviceActionResult

result returned to the host, keyed by BackupActionOutputKeys

Public properties

phase

open val phase: Int

Lifecycle phase when this action runs.