# InMemoryDatabaseRule

Artifact: [androidx.media3:media3-test-utils](https://developer.android.com/jetpack/androidx/releases/media3) [View Source](https://cs.android.com/search?q=file:androidx/media3/test/utils/InMemoryDatabaseRule.java+class:androidx.media3.test.utils.InMemoryDatabaseRule)

*** ** * ** ***


```
@UnstableApi
class InMemoryDatabaseRule : TestRule
```

<br />

*** ** * ** ***

A JUnit `https://junit.org/junit4/javadoc/latest/org/junit/Rule.html` that creates (and cleans up) in-memory databases and `https://developer.android.com/reference/kotlin/androidx/media3/datasource/cache/SimpleCache` instances.

## Summary

| ### Public functions |
|---|---|
| `https://junit.org/junit4/javadoc/latest/org/junit/runners/model/Statement.html!` | `https://developer.android.com/reference/kotlin/androidx/media3/test/utils/InMemoryDatabaseRule#apply(org.junit.runners.model.Statement,org.junit.runner.Description)(base: https://junit.org/junit4/javadoc/latest/org/junit/runners/model/Statement.html!, description: https://junit.org/junit4/javadoc/latest/org/junit/runner/Description.html!)` |
| `java-static https://developer.android.com/reference/kotlin/androidx/media3/test/utils/InMemoryDatabaseRule!` | `https://developer.android.com/reference/kotlin/androidx/media3/test/utils/InMemoryDatabaseRule#create()()` |
| `https://developer.android.com/reference/kotlin/androidx/media3/database/DatabaseProvider!` | `https://developer.android.com/reference/kotlin/androidx/media3/test/utils/InMemoryDatabaseRule#createDatabaseProvider()()` Returns the `https://developer.android.com/reference/kotlin/androidx/media3/database/DatabaseProvider` created by this rule. |
| `https://developer.android.com/reference/kotlin/androidx/media3/datasource/cache/SimpleCache!` | `https://developer.android.com/reference/kotlin/androidx/media3/test/utils/InMemoryDatabaseRule#createSimpleCache()()` Returns a `https://developer.android.com/reference/kotlin/androidx/media3/datasource/cache/SimpleCache` created by this rule. |

## Public functions

### apply

```
fun apply(base: Statement!, description: Description!): Statement!
```

### create

```
java-static fun create(): InMemoryDatabaseRule!
```

### createDatabaseProvider

```
fun createDatabaseProvider(): DatabaseProvider!
```

Returns the `https://developer.android.com/reference/kotlin/androidx/media3/database/DatabaseProvider` created by this rule.

### createSimpleCache

```
fun createSimpleCache(): SimpleCache!
```

Returns a `https://developer.android.com/reference/kotlin/androidx/media3/datasource/cache/SimpleCache` created by this rule.

| Throws |
|---|---|
| `https://developer.android.com/reference/java/io/IOException.html` |   |