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

*** ** * ** ***


```
public final class OkioStorage<T extends Object> implements Storage<@NonNull T>
```

<br />

*** ** * ** ***

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

## Summary

| ### Public constructors |
|---|
| `<T extends https://developer.android.com/reference/java/lang/Object.html> https://developer.android.com/reference/androidx/datastore/core/okio/OkioStorage#OkioStorage(okio.FileSystem,androidx.datastore.core.okio.OkioSerializer,kotlin.Function2,kotlin.Function0)( @https://developer.android.com/reference/androidx/annotation/NonNull https://lysine.dev/okio/3.x/okio/okio/-file-system/index.html fileSystem, @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/datastore/core/okio/OkioSerializer<@https://developer.android.com/reference/androidx/annotation/NonNull T> serializer, @https://developer.android.com/reference/androidx/annotation/NonNull Function2<@https://developer.android.com/reference/androidx/annotation/NonNull https://lysine.dev/okio/3.x/okio/okio/-path/index.html, @https://developer.android.com/reference/androidx/annotation/NonNull https://lysine.dev/okio/3.x/okio/okio/-file-system/index.html, @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/datastore/core/InterProcessCoordinator> coordinatorProducer, @https://developer.android.com/reference/androidx/annotation/NonNull Function0<@https://developer.android.com/reference/androidx/annotation/NonNull https://lysine.dev/okio/3.x/okio/okio/-path/index.html> producePath )` |

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

## Public constructors

### OkioStorage

```
public <T extends Object> OkioStorage(
    @NonNull FileSystem fileSystem,
    @NonNull OkioSerializer<@NonNull T> serializer,
    @NonNull Function2<@NonNull Path, @NonNull FileSystem, @NonNull InterProcessCoordinator> coordinatorProducer,
    @NonNull Function0<@NonNull Path> producePath
)
```

| Parameters |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://lysine.dev/okio/3.x/okio/okio/-file-system/index.html fileSystem` | The file system to perform IO operations on. |
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/datastore/core/okio/OkioSerializer<@https://developer.android.com/reference/androidx/annotation/NonNull T> serializer` | The serializer for `T`. |
| `@https://developer.android.com/reference/androidx/annotation/NonNull Function2<@https://developer.android.com/reference/androidx/annotation/NonNull https://lysine.dev/okio/3.x/okio/okio/-path/index.html, @https://developer.android.com/reference/androidx/annotation/NonNull https://lysine.dev/okio/3.x/okio/okio/-file-system/index.html, @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/datastore/core/InterProcessCoordinator> coordinatorProducer` | The producer to provide `https://developer.android.com/reference/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. |
| `@https://developer.android.com/reference/androidx/annotation/NonNull Function0<@https://developer.android.com/reference/androidx/annotation/NonNull https://lysine.dev/okio/3.x/okio/okio/-path/index.html> producePath` | The file producer that returns the file path that will be read and written. |

## Public methods

### createConnection

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

```
public @NonNull StorageConnection<@NonNull T> createConnection()
```

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

Should be closed after usage.

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