# Storage

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

*** ** * ** ***


```
public interface Storage<T extends Object>
```

<br />

Known direct subclasses [FileStorage](https://developer.android.com/reference/androidx/datastore/core/FileStorage), [OkioStorage](https://developer.android.com/reference/androidx/datastore/core/okio/OkioStorage), [WebLocalStorage](https://developer.android.com/reference/androidx/datastore/core/okio/WebLocalStorage), [WebOpfsStorage](https://developer.android.com/reference/androidx/datastore/core/okio/WebOpfsStorage), [WebSessionStorage](https://developer.android.com/reference/androidx/datastore/core/okio/WebSessionStorage)

|---|---|
| `https://developer.android.com/reference/androidx/datastore/core/FileStorage` | The Java IO File version of the Storage interface. |
| `https://developer.android.com/reference/androidx/datastore/core/okio/OkioStorage` | OKIO implementation of the Storage interface, providing cross platform IO using the OKIO library. |
| `https://developer.android.com/reference/androidx/datastore/core/okio/WebLocalStorage` |   |
| `https://developer.android.com/reference/androidx/datastore/core/okio/WebOpfsStorage` |   |
| `https://developer.android.com/reference/androidx/datastore/core/okio/WebSessionStorage` |   |

*** ** * ** ***

Storage provides a way to create StorageConnections that allow read and write a particular type of data. Storage is used to construct DataStore objects, and encapsulates all the specifics of the data format and persistence.

Implementers provide the specifics of how and where the data is stored.

## Summary

| ### Public methods |
|---|---|
| `abstract @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/Storage#createConnection()()` Creates a storage connection which allows reading and writing to the underlying storage. |

## Public methods

### createConnection

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

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