# 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)

*** ** * ** ***


```
class StorageDomain.Database : StorageDomain
```

<br />

|---|---|---|
| [kotlin.Any](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-any/index.html) |||
| ↳ | [androidx.test.backup.host.StorageDomain](https://developer.android.com/reference/kotlin/androidx/test/backup/host/StorageDomain) ||
|   | ↳ | [androidx.test.backup.host.StorageDomain.Database](https://developer.android.com/reference/kotlin/androidx/test/backup/host/StorageDomain.Database) |

*** ** * ** ***

Targets structured SQLite/Room database records.

## Summary

| ### Public constructors |
|---|
| `https://developer.android.com/reference/kotlin/androidx/test/backup/host/StorageDomain.Database#Database(kotlin.String,kotlin.String,kotlin.String,kotlin.Any,kotlin.collections.Map,kotlin.Boolean)( dbName: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html, table: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html, primaryKeyCol: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html, primaryKeyVal: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-any/index.html, columnValues: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-map/index.html<https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html, https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-any/index.html?>, isDeviceProtectedStorage: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html )` |

| ### Public functions |
|---|---|
| `open operator https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` | `https://developer.android.com/reference/kotlin/androidx/test/backup/host/StorageDomain.Database#equals(kotlin.Any)(other: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-any/index.html?)` |
| `open https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `https://developer.android.com/reference/kotlin/androidx/test/backup/host/StorageDomain.Database#hashCode()()` |
| `open https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html` | `https://developer.android.com/reference/kotlin/androidx/test/backup/host/StorageDomain.Database#toString()()` |

| ### Public properties |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-map/index.html<https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html, https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-any/index.html?>` | `https://developer.android.com/reference/kotlin/androidx/test/backup/host/StorageDomain.Database#columnValues()` A non-empty Map of column names to their values to populate or verify. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html` | `https://developer.android.com/reference/kotlin/androidx/test/backup/host/StorageDomain.Database#dbName()` The name of the SQLite database file on the device. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` | `https://developer.android.com/reference/kotlin/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://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html` | `https://developer.android.com/reference/kotlin/androidx/test/backup/host/StorageDomain.Database#primaryKeyCol()` The column name of the primary key used to identify the target record. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-any/index.html` | `https://developer.android.com/reference/kotlin/androidx/test/backup/host/StorageDomain.Database#primaryKeyVal()` The value of the primary key used to identify the target record. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html` | `https://developer.android.com/reference/kotlin/androidx/test/backup/host/StorageDomain.Database#table()` The target table name to insert into or query from. |

## Public constructors

### Database

```
Database(
    dbName: String,
    table: String,
    primaryKeyCol: String,
    primaryKeyVal: Any,
    columnValues: Map<String, Any?>,
    isDeviceProtectedStorage: Boolean = false
)
```

## Public functions

### equals

```
open operator fun equals(other: Any?): Boolean
```

### hashCode

```
open fun hashCode(): Int
```

### toString

```
open fun toString(): String
```

## Public properties

### columnValues

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

```
val columnValues: Map<String, Any?>
```

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/kotlin/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/kotlin/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/kotlin/androidx/test/backup/host/StorageDomain.Database#primaryKeyVal()` is written to that column. The domain keeps a copy of it.

### dbName

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

```
val dbName: String
```

The name of the SQLite database file on the device.

### isDeviceProtectedStorage

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

```
val isDeviceProtectedStorage: Boolean
```

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`.

### primaryKeyCol

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

```
val primaryKeyCol: String
```

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

### primaryKeyVal

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

```
val primaryKeyVal: Any
```

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

### table

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

```
val table: String
```

The target table name to insert into or query from.