# StorageDomain.Database

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

*** ** * ** ***


```
public final class StorageDomain.Database extends StorageDomain
```

<br />

|---|---|---|
| [java.lang.Object](https://developer.android.com/reference/java/lang/Object.html) |||
| ↳ | [androidx.test.backup.host.StorageDomain](https://developer.android.com/reference/androidx/test/backup/host/StorageDomain) ||
|   | ↳ | [androidx.test.backup.host.StorageDomain.Database](https://developer.android.com/reference/androidx/test/backup/host/StorageDomain.Database) |

*** ** * ** ***

Targets structured SQLite/Room database records.

## Summary

| ### Public constructors |
|---|
| `https://developer.android.com/reference/androidx/test/backup/host/StorageDomain.Database#Database(kotlin.String,kotlin.String,kotlin.String,kotlin.Any,kotlin.collections.Map,kotlin.Boolean)( @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/lang/String.html dbName, @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/lang/String.html table, @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/lang/String.html primaryKeyCol, @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/lang/Object.html primaryKeyVal, @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/util/Map.html<@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/lang/String.html, https://developer.android.com/reference/java/lang/Object.html> columnValues, boolean isDeviceProtectedStorage )` |

| ### Public methods |
|---|---|
| `boolean` | `https://developer.android.com/reference/androidx/test/backup/host/StorageDomain.Database#equals(kotlin.Any)(https://developer.android.com/reference/java/lang/Object.html other)` |
| `final @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/util/Map.html<@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/lang/String.html, https://developer.android.com/reference/java/lang/Object.html>` | `https://developer.android.com/reference/androidx/test/backup/host/StorageDomain.Database#getColumnValues()()` A non-empty Map of column names to their values to populate or verify. |
| `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/host/StorageDomain.Database#getDbName()()` The name of the SQLite database file on the device. |
| `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/host/StorageDomain.Database#getPrimaryKeyCol()()` The column name of the primary key used to identify the target record. |
| `final @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/lang/Object.html` | `https://developer.android.com/reference/androidx/test/backup/host/StorageDomain.Database#getPrimaryKeyVal()()` The value of the primary key used to identify the target record. |
| `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/host/StorageDomain.Database#getTable()()` The target table name to insert into or query from. |
| `int` | `https://developer.android.com/reference/androidx/test/backup/host/StorageDomain.Database#hashCode()()` |
| `final boolean` | `https://developer.android.com/reference/androidx/test/backup/host/StorageDomain.Database#isDeviceProtectedStorage()()` Whether the database is in device-protected storage, which is available before the user first unlocks the device, rather than in the default storage of the app. |
| `@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/host/StorageDomain.Database#toString()()` |

## Public constructors

### Database

```
public Database(
    @NonNull String dbName,
    @NonNull String table,
    @NonNull String primaryKeyCol,
    @NonNull Object primaryKeyVal,
    @NonNull Map<@NonNull String, Object> columnValues,
    boolean isDeviceProtectedStorage
)
```

## Public methods

### equals

```
public boolean equals(Object other)
```

### getColumnValues

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

```
public final @NonNull Map<@NonNull String, Object> getColumnValues()
```

A non-empty Map of column names to their values to populate or verify. Supported types are: String, Int, Long, Float, Double, Boolean, or null, which stands for SQL `NULL`. It may include `https://developer.android.com/reference/androidx/test/backup/host/StorageDomain.Database#primaryKeyCol()`, matched case-insensitively like SQLite column names, but only with a value whose string form equals that of `https://developer.android.com/reference/androidx/test/backup/host/StorageDomain.Database#primaryKeyVal()`; otherwise construction fails with an `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-illegal-argument-exception/index.html`. When it is omitted, `https://developer.android.com/reference/androidx/test/backup/host/StorageDomain.Database#primaryKeyVal()` is written to that column. The domain keeps a copy of it.

### getDbName

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

```
public final @NonNull String getDbName()
```

The name of the SQLite database file on the device.

### getPrimaryKeyCol

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

```
public final @NonNull String getPrimaryKeyCol()
```

The column name of the primary key used to identify the target record.

### getPrimaryKeyVal

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

```
public final @NonNull Object getPrimaryKeyVal()
```

The value of the primary key used to identify the target record. Supported types are: String, Int, Long, Float, Double, Boolean.

### getTable

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

```
public final @NonNull String getTable()
```

The target table name to insert into or query from.

### hashCode

```
public int hashCode()
```

### isDeviceProtectedStorage

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

```
public final boolean isDeviceProtectedStorage()
```

Whether the database is in device-protected storage, which is available before the user first unlocks the device, rather than in the default storage of the app. That is credential-encrypted storage, unless the app sets `android:defaultToDeviceProtectedStorage`.

### toString

```
public @NonNull String toString()
```