# BackupActionInputKeys

Artifact: [androidx.test.backup:backup](https://developer.android.com/jetpack/androidx/releases/test-backup) [View Source](https://cs.android.com/search?q=file:androidx/test/backup/BackupActionKeys.kt+class:androidx.test.backup.BackupActionInputKeys) Added in [1.0.0-alpha04](https://developer.android.com/jetpack/androidx/releases/test-backup#1.0.0-alpha04)

*** ** * ** ***


```
public static class BackupActionInputKeys
```

<br />

*** ** * ** ***

Keys accepted in `https://developer.android.com/reference/androidx/test/backup/BackupDeviceActionArgs#payload()` by the actions bundled with this library.

Those actions are `https://developer.android.com/reference/androidx/test/backup/actions/PopulateStorageAction` and `https://developer.android.com/reference/androidx/test/backup/actions/AssertStorageAction`.

Every value in the payload is a `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html`; non-string data is encoded as described on the individual key. Keys that an action does not recognize are ignored, so a single payload may be reused for both the populate and the verify phase of a flow.

Which keys apply depends on `https://developer.android.com/reference/androidx/test/backup/BackupActionInputKeys#STORAGE_TYPE()`:

- `https://developer.android.com/reference/androidx/test/backup/BackupActionValues#STORAGE_TYPE_PREFS()` and `https://developer.android.com/reference/androidx/test/backup/BackupActionValues#STORAGE_TYPE_DATASTORE_PREFS()` use `https://developer.android.com/reference/androidx/test/backup/BackupActionInputKeys#PREF_NAME()`, `https://developer.android.com/reference/androidx/test/backup/BackupActionInputKeys#PREF_KEY()`, `https://developer.android.com/reference/androidx/test/backup/BackupActionInputKeys#VALUE()`, `https://developer.android.com/reference/androidx/test/backup/BackupActionInputKeys#VALUE_TYPE()`, `https://developer.android.com/reference/androidx/test/backup/BackupActionInputKeys#EXPECTED()` and `https://developer.android.com/reference/androidx/test/backup/BackupActionInputKeys#EXPECT_NULL()`.

- `https://developer.android.com/reference/androidx/test/backup/BackupActionValues#STORAGE_TYPE_DATABASE()` uses `https://developer.android.com/reference/androidx/test/backup/BackupActionInputKeys#DB_NAME()`, `https://developer.android.com/reference/androidx/test/backup/BackupActionInputKeys#TABLE()`, `https://developer.android.com/reference/androidx/test/backup/BackupActionInputKeys#VALUES()`, `https://developer.android.com/reference/androidx/test/backup/BackupActionInputKeys#KEY_COL()`, `https://developer.android.com/reference/androidx/test/backup/BackupActionInputKeys#KEY_VAL()`, `https://developer.android.com/reference/androidx/test/backup/BackupActionInputKeys#EXPECTED_COL()`, `https://developer.android.com/reference/androidx/test/backup/BackupActionInputKeys#EXPECTED_VAL()` and `https://developer.android.com/reference/androidx/test/backup/BackupActionInputKeys#EXPECT_NULL()`.

- `https://developer.android.com/reference/androidx/test/backup/BackupActionValues#STORAGE_TYPE_FILES()` uses `https://developer.android.com/reference/androidx/test/backup/BackupActionInputKeys#PATH()`, `https://developer.android.com/reference/androidx/test/backup/BackupActionInputKeys#VALUE()`, `https://developer.android.com/reference/androidx/test/backup/BackupActionInputKeys#IS_BINARY()`, `https://developer.android.com/reference/androidx/test/backup/BackupActionInputKeys#EXPECTED()` and `https://developer.android.com/reference/androidx/test/backup/BackupActionInputKeys#EXPECT_NULL()`.

`https://developer.android.com/reference/androidx/test/backup/BackupActionInputKeys#IS_DEVICE_PROTECTED()` applies to every storage type.

Custom `https://developer.android.com/reference/androidx/test/backup/BackupDeviceAction` implementations are free to define their own keys; this object only describes the vocabulary understood by the bundled actions. Result keys live in a separate namespace, `https://developer.android.com/reference/androidx/test/backup/BackupActionOutputKeys`.

## Summary

| ### Constants |
|---|---|
| `static final @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/lang/String.html` | `https://developer.android.com/reference/androidx/test/backup/BackupActionInputKeys#DB_NAME()` File name of the SQLite database. |
| `static final @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/lang/String.html` | `https://developer.android.com/reference/androidx/test/backup/BackupActionInputKeys#EXPECTED()` Expected content during verification of preference or file storage. |
| `static final @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/lang/String.html` | `https://developer.android.com/reference/androidx/test/backup/BackupActionInputKeys#EXPECTED_COL()` Name of the column whose content is verified. |
| `static final @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/lang/String.html` | `https://developer.android.com/reference/androidx/test/backup/BackupActionInputKeys#EXPECTED_VAL()` Expected content of `https://developer.android.com/reference/androidx/test/backup/BackupActionInputKeys#EXPECTED_COL()`, as the string form of the column value. |
| `static final @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/lang/String.html` | `https://developer.android.com/reference/androidx/test/backup/BackupActionInputKeys#EXPECT_NULL()` Whether the data is expected to be absent. |
| `static final @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/lang/String.html` | `https://developer.android.com/reference/androidx/test/backup/BackupActionInputKeys#IS_BINARY()` Whether `https://developer.android.com/reference/androidx/test/backup/BackupActionInputKeys#VALUE()` and `https://developer.android.com/reference/androidx/test/backup/BackupActionInputKeys#EXPECTED()` carry Base64-encoded binary data rather than text. |
| `static final @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/lang/String.html` | `https://developer.android.com/reference/androidx/test/backup/BackupActionInputKeys#IS_DEVICE_PROTECTED()` Whether to operate on device-protected (direct boot aware) storage. |
| `static final @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/lang/String.html` | `https://developer.android.com/reference/androidx/test/backup/BackupActionInputKeys#KEY_COL()` Name of the column that identifies the row. |
| `static final @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/lang/String.html` | `https://developer.android.com/reference/androidx/test/backup/BackupActionInputKeys#KEY_VAL()` Value of `https://developer.android.com/reference/androidx/test/backup/BackupActionInputKeys#KEY_COL()` identifying the row. |
| `static final @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/lang/String.html` | `https://developer.android.com/reference/androidx/test/backup/BackupActionInputKeys#PATH()` Location of the file to write or read. |
| `static final @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/lang/String.html` | `https://developer.android.com/reference/androidx/test/backup/BackupActionInputKeys#PREF_KEY()` Key within the `https://developer.android.com/reference/android/content/SharedPreferences.html` file or the Preferences DataStore. |
| `static final @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/lang/String.html` | `https://developer.android.com/reference/androidx/test/backup/BackupActionInputKeys#PREF_NAME()` Name of the `https://developer.android.com/reference/android/content/SharedPreferences.html` file or of the Preferences DataStore. |
| `static final @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/lang/String.html` | `https://developer.android.com/reference/androidx/test/backup/BackupActionInputKeys#STORAGE_TYPE()` Storage medium the action operates on. |
| `static final @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/lang/String.html` | `https://developer.android.com/reference/androidx/test/backup/BackupActionInputKeys#TABLE()` Table name inside the SQLite database. |
| `static final @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/lang/String.html` | `https://developer.android.com/reference/androidx/test/backup/BackupActionInputKeys#VALUE()` Value to write, and the fallback expected value during verification when `https://developer.android.com/reference/androidx/test/backup/BackupActionInputKeys#EXPECTED()` is absent. |
| `static final @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/lang/String.html` | `https://developer.android.com/reference/androidx/test/backup/BackupActionInputKeys#VALUES()` Column values to insert, as an `application/x-www-form-urlencoded` string. |
| `static final @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/lang/String.html` | `https://developer.android.com/reference/androidx/test/backup/BackupActionInputKeys#VALUE_TYPE()` Type used to store and read back a preference `https://developer.android.com/reference/androidx/test/backup/BackupActionInputKeys#VALUE()`. |

| ### Public fields |
|---|---|
| `static @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/test/backup/BackupActionInputKeys` | `https://developer.android.com/reference/androidx/test/backup/BackupActionInputKeys#INSTANCE()` |

## Constants

### DB_NAME

Added in [1.0.0-alpha04](https://developer.android.com/jetpack/androidx/releases/test-backup#1.0.0-alpha04)

```
public static final @NonNull String DB_NAME
```

File name of the SQLite database. Required for database storage.

### EXPECTED

Added in [1.0.0-alpha04](https://developer.android.com/jetpack/androidx/releases/test-backup#1.0.0-alpha04)

```
public static final @NonNull String EXPECTED
```

Expected content during verification of preference or file storage.

Falls back to `https://developer.android.com/reference/androidx/test/backup/BackupActionInputKeys#VALUE()` when absent, which lets the same payload seed and verify a domain. Preferences are compared as values of `https://developer.android.com/reference/androidx/test/backup/BackupActionInputKeys#VALUE_TYPE()` rather than as strings, so `"1.50"` matches a stored float of `1.5`. Database verification uses `https://developer.android.com/reference/androidx/test/backup/BackupActionInputKeys#EXPECTED_COL()` and `https://developer.android.com/reference/androidx/test/backup/BackupActionInputKeys#EXPECTED_VAL()` instead.

### EXPECTED_COL

Added in [1.0.0-alpha04](https://developer.android.com/jetpack/androidx/releases/test-backup#1.0.0-alpha04)

```
public static final @NonNull String EXPECTED_COL
```

Name of the column whose content is verified. Ignored when `https://developer.android.com/reference/androidx/test/backup/BackupActionInputKeys#VALUES()` is present.

### EXPECTED_VAL

Added in [1.0.0-alpha04](https://developer.android.com/jetpack/androidx/releases/test-backup#1.0.0-alpha04)

```
public static final @NonNull String EXPECTED_VAL
```

Expected content of `https://developer.android.com/reference/androidx/test/backup/BackupActionInputKeys#EXPECTED_COL()`, as the string form of the column value.

SQLite has no boolean type, so booleans are compared as `"true"` or `"false"`. Ignored when `https://developer.android.com/reference/androidx/test/backup/BackupActionInputKeys#VALUES()` is present.

### EXPECT_NULL

Added in [1.0.0-alpha04](https://developer.android.com/jetpack/androidx/releases/test-backup#1.0.0-alpha04)

```
public static final @NonNull String EXPECT_NULL
```

Whether the data is expected to be absent.

Parsed with `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.text/index.html`. When enabled, verification asserts that the preference key, the database row or the file is absent, without consulting any expected value, and populating a preference removes its key.

### IS_BINARY

Added in [1.0.0-alpha04](https://developer.android.com/jetpack/androidx/releases/test-backup#1.0.0-alpha04)

```
public static final @NonNull String IS_BINARY
```

Whether `https://developer.android.com/reference/androidx/test/backup/BackupActionInputKeys#VALUE()` and `https://developer.android.com/reference/androidx/test/backup/BackupActionInputKeys#EXPECTED()` carry Base64-encoded binary data rather than text.

Parsed with `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.text/index.html`. When enabled, the payload is decoded with `https://developer.android.com/reference/android/util/Base64.html#DEFAULT` and the file is compared byte for byte.

### IS_DEVICE_PROTECTED

Added in [1.0.0-alpha04](https://developer.android.com/jetpack/androidx/releases/test-backup#1.0.0-alpha04)

```
public static final @NonNull String IS_DEVICE_PROTECTED
```

Whether to operate on device-protected (direct boot aware) storage.

Parsed with `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.text/index.html`, so `"true"` in any casing enables it and every other value, including an absent key, leaves it disabled. When enabled, the action runs against `https://developer.android.com/reference/android/content/Context.html#createDeviceProtectedStorageContext()` instead of the default storage of the app, which is credential-encrypted unless the app sets `android:defaultToDeviceProtectedStorage`.

### KEY_COL

Added in [1.0.0-alpha04](https://developer.android.com/jetpack/androidx/releases/test-backup#1.0.0-alpha04)

```
public static final @NonNull String KEY_COL
```

Name of the column that identifies the row.

Required for database verification, which checks that exactly one row has `https://developer.android.com/reference/androidx/test/backup/BackupActionInputKeys#KEY_VAL()` in this column, or none with `https://developer.android.com/reference/androidx/test/backup/BackupActionInputKeys#EXPECT_NULL()`. Optional for population: when both this key and `https://developer.android.com/reference/androidx/test/backup/BackupActionInputKeys#KEY_VAL()` are present, rows with that key are deleted before the insert, so repeating a populate leaves a single row.

### KEY_VAL

Added in [1.0.0-alpha04](https://developer.android.com/jetpack/androidx/releases/test-backup#1.0.0-alpha04)

```
public static final @NonNull String KEY_VAL
```

Value of `https://developer.android.com/reference/androidx/test/backup/BackupActionInputKeys#KEY_COL()` identifying the row. Required for database verification.

### PATH

Added in [1.0.0-alpha04](https://developer.android.com/jetpack/androidx/releases/test-backup#1.0.0-alpha04)

```
public static final @NonNull String PATH
```

Location of the file to write or read.

Absolute paths are used verbatim. Relative paths are resolved against `https://developer.android.com/reference/android/content/Context.html#getFilesDir()` of the context selected by `https://developer.android.com/reference/androidx/test/backup/BackupActionInputKeys#IS_DEVICE_PROTECTED()`.

### PREF_KEY

Added in [1.0.0-alpha04](https://developer.android.com/jetpack/androidx/releases/test-backup#1.0.0-alpha04)

```
public static final @NonNull String PREF_KEY
```

Key within the `https://developer.android.com/reference/android/content/SharedPreferences.html` file or the Preferences DataStore. Required for preference storage.

### PREF_NAME

Added in [1.0.0-alpha04](https://developer.android.com/jetpack/androidx/releases/test-backup#1.0.0-alpha04)

```
public static final @NonNull String PREF_NAME
```

Name of the `https://developer.android.com/reference/android/content/SharedPreferences.html` file or of the Preferences DataStore.

Required for a Preferences DataStore. For a SharedPreferences file, defaults to `https://developer.android.com/reference/androidx/test/backup/BackupActionValues#DEFAULT_PREF_NAME()` when absent.

### STORAGE_TYPE

Added in [1.0.0-alpha04](https://developer.android.com/jetpack/androidx/releases/test-backup#1.0.0-alpha04)

```
public static final @NonNull String STORAGE_TYPE
```

Storage medium the action operates on.

Must be one of `https://developer.android.com/reference/androidx/test/backup/BackupActionValues#STORAGE_TYPE_PREFS()`, `https://developer.android.com/reference/androidx/test/backup/BackupActionValues#STORAGE_TYPE_DATASTORE_PREFS()`, `https://developer.android.com/reference/androidx/test/backup/BackupActionValues#STORAGE_TYPE_DATABASE()` or `https://developer.android.com/reference/androidx/test/backup/BackupActionValues#STORAGE_TYPE_FILES()`, matched case-insensitively. Defaults to `https://developer.android.com/reference/androidx/test/backup/BackupActionValues#STORAGE_TYPE_PREFS()` when absent. Any other value fails the action.

### TABLE

Added in [1.0.0-alpha04](https://developer.android.com/jetpack/androidx/releases/test-backup#1.0.0-alpha04)

```
public static final @NonNull String TABLE
```

Table name inside the SQLite database. Required for database storage.

### VALUE

Added in [1.0.0-alpha04](https://developer.android.com/jetpack/androidx/releases/test-backup#1.0.0-alpha04)

```
public static final @NonNull String VALUE
```

Value to write, and the fallback expected value during verification when `https://developer.android.com/reference/androidx/test/backup/BackupActionInputKeys#EXPECTED()` is absent.

For preference storage the string is converted according to `https://developer.android.com/reference/androidx/test/backup/BackupActionInputKeys#VALUE_TYPE()`. For file storage it is the file body, Base64-encoded when `https://developer.android.com/reference/androidx/test/backup/BackupActionInputKeys#IS_BINARY()` is set.

### VALUES

Added in [1.0.0-alpha04](https://developer.android.com/jetpack/androidx/releases/test-backup#1.0.0-alpha04)

```
public static final @NonNull String VALUES
```

Column values to insert, as an `application/x-www-form-urlencoded` string.

Pairs are separated by `&` and each pair is `name=value`, with both the name and the value percent-encoded in UTF-8 exactly as `https://developer.android.com/reference/java/net/URLEncoder.html` produces. Encoding is what makes column values containing `&`, `=`, `%` or `+` round-trip correctly; a literal `+` decodes back to a space, so it must be encoded as `%2B`. A name without `=` stands for SQL `NULL`, whereas `name=` is the empty string.

For example, the columns `name = "a&b"`, `city = "Rio"` and `note = NULL` are expressed as `"name=a%26b&city=Rio&note"`. Malformed pairs fail the action rather than being skipped.

During verification this key replaces the `https://developer.android.com/reference/androidx/test/backup/BackupActionInputKeys#EXPECTED_COL()` / `https://developer.android.com/reference/androidx/test/backup/BackupActionInputKeys#EXPECTED_VAL()` pair. Every pair it carries is checked against the row, so a restore that corrupts any column of the row fails, and all mismatches are reported together. A malformed value fails the action rather than falling back to `https://developer.android.com/reference/androidx/test/backup/BackupActionInputKeys#EXPECTED_COL()` and `https://developer.android.com/reference/androidx/test/backup/BackupActionInputKeys#EXPECTED_VAL()`.

### VALUE_TYPE

Added in [1.0.0-alpha04](https://developer.android.com/jetpack/androidx/releases/test-backup#1.0.0-alpha04)

```
public static final @NonNull String VALUE_TYPE
```

Type used to store and read back a preference `https://developer.android.com/reference/androidx/test/backup/BackupActionInputKeys#VALUE()`.

Must be one of `https://developer.android.com/reference/androidx/test/backup/BackupActionValues#VALUE_TYPE_INT()`, `https://developer.android.com/reference/androidx/test/backup/BackupActionValues#VALUE_TYPE_LONG()`, `https://developer.android.com/reference/androidx/test/backup/BackupActionValues#VALUE_TYPE_FLOAT()`, `https://developer.android.com/reference/androidx/test/backup/BackupActionValues#VALUE_TYPE_BOOLEAN()`, `https://developer.android.com/reference/androidx/test/backup/BackupActionValues#VALUE_TYPE_STRING()` or `https://developer.android.com/reference/androidx/test/backup/BackupActionValues#VALUE_TYPE_STRING_SET()`, or, for a Preferences DataStore only, `https://developer.android.com/reference/androidx/test/backup/BackupActionValues#VALUE_TYPE_DOUBLE()` or `https://developer.android.com/reference/androidx/test/backup/BackupActionValues#VALUE_TYPE_BYTES()`, matched case-insensitively. Defaults to `https://developer.android.com/reference/androidx/test/backup/BackupActionValues#VALUE_TYPE_STRING()` when absent. Any other value fails the action, as does a `https://developer.android.com/reference/androidx/test/backup/BackupActionInputKeys#VALUE()` or `https://developer.android.com/reference/androidx/test/backup/BackupActionInputKeys#EXPECTED()` that does not parse as this type. Booleans accept only `"true"` and `"false"`, in any casing.

## Public fields

### INSTANCE

Added in [1.0.0-alpha04](https://developer.android.com/jetpack/androidx/releases/test-backup#1.0.0-alpha04)

```
public static @NonNull BackupActionInputKeys INSTANCE
```