# OkioStorage

Artifact: [androidx.datastore:datastore-core-okio](https://developer.android.com/jetpack/androidx/releases/datastore) [View Source](https://cs.android.com/search?q=file:androidx/datastore/core/okio/OkioStorage.kt+class:androidx.datastore.core.okio.OkioStorage) Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/datastore#1.1.0)

*** ** * ** ***

Common/AllJavaScript
- Cmn

  ```
  class OkioStorage<T : Any?> : Storage<T>
  ```

*** ** * ** ***

OKIO implementation of the Storage interface, providing cross platform IO using the OKIO library.

## Summary

| ### Public constructors |
|---|---|
| `<T : https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-any/index.html?> https://developer.android.com/reference/kotlin/androidx/datastore/core/okio/OkioStorage#OkioStorage(okio.FileSystem,androidx.datastore.core.okio.OkioSerializer,kotlin.Function2,kotlin.Function0)( fileSystem: https://lysine.dev/okio/3.x/okio/okio/-file-system/index.html, serializer: https://developer.android.com/reference/kotlin/androidx/datastore/core/okio/OkioSerializer<T>, coordinatorProducer: (https://lysine.dev/okio/3.x/okio/okio/-path/index.html, https://lysine.dev/okio/3.x/okio/okio/-file-system/index.html) -> https://developer.android.com/reference/kotlin/androidx/datastore/core/InterProcessCoordinator, producePath: () -> https://lysine.dev/okio/3.x/okio/okio/-path/index.html )` | Cmn |

| ### Public functions |
|---|---|---|
| `open https://developer.android.com/reference/kotlin/androidx/datastore/core/StorageConnection<T>` | `https://developer.android.com/reference/kotlin/androidx/datastore/core/okio/OkioStorage#createConnection()()` Creates a storage connection which allows reading and writing to the underlying storage. | Cmn |

## Public constructors

### OkioStorage

Cmn

```
<T : Any?> OkioStorage(
    fileSystem: FileSystem,
    serializer: OkioSerializer<T>,
    coordinatorProducer: (Path, FileSystem) -> InterProcessCoordinator = { path, _ ->
        createSingleProcessCoordinator(path)
    },
    producePath: () -> Path
)
```

| Parameters |
|---|---|
| `fileSystem: https://lysine.dev/okio/3.x/okio/okio/-file-system/index.html` | The file system to perform IO operations on. |
| `serializer: https://developer.android.com/reference/kotlin/androidx/datastore/core/okio/OkioSerializer<T>` | The serializer for `T`. |
| `coordinatorProducer: (https://lysine.dev/okio/3.x/okio/okio/-path/index.html, https://lysine.dev/okio/3.x/okio/okio/-file-system/index.html) -> https://developer.android.com/reference/kotlin/androidx/datastore/core/InterProcessCoordinator = { path, _ -> createSingleProcessCoordinator(path) }` | The producer to provide `https://developer.android.com/reference/kotlin/androidx/datastore/core/InterProcessCoordinator` that coordinates IO operations across processes if needed. By default it provides single process coordinator, which doesn't support cross process use cases. |
| `producePath: () -> https://lysine.dev/okio/3.x/okio/okio/-path/index.html` | The file producer that returns the file path that will be read and written. |

## Public functions

### createConnection

Cmn Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/datastore#1.1.0)

```
open fun createConnection(): StorageConnection<T>
```

Creates a storage connection which allows reading and writing to the underlying storage.

Should be closed after usage.

| Throws |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/datastore/core/IOException` | Unrecoverable IO exception when trying to access the underlying storage. |