# Storage

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

*** ** * ** ***

Kotlin\|[Java](https://developer.android.com/reference/androidx/datastore/core/Storage "View this page in Java")
Common/AllAndroid/JVMNative/C/iOSJavaScript
  - Cmn  

  ```
  interface Storage<T : Any?>
```  
Known direct subclasses  
[FileStorage](https://developer.android.com/reference/kotlin/androidx/datastore/core/FileStorage),[OkioStorage](https://developer.android.com/reference/kotlin/androidx/datastore/core/okio/OkioStorage),[WebStorage](https://developer.android.com/reference/kotlin/androidx/datastore/core/okio/WebStorage)  

|--------------------------------------------------------------------------------------------------------|---------------------------------------------------------------------------------------------------|
| [FileStorage](https://developer.android.com/reference/kotlin/androidx/datastore/core/FileStorage)      | The Java IO File version of the Storageinterface.                                                 |
| [OkioStorage](https://developer.android.com/reference/kotlin/androidx/datastore/core/okio/OkioStorage) | OKIO implementation of the Storage interface, providing cross platform IO using the OKIO library. |
| [WebStorage](https://developer.android.com/reference/kotlin/androidx/datastore/core/okio/WebStorage)   |                                                                                                   |

*** ** * ** ***

Storage provides a way to create StorageConnections that allow read and write a particular typeof 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 functions                                                |
|--------------------------------------------------------------------------------------------------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|-----|
| [StorageConnection](https://developer.android.com/reference/kotlin/androidx/datastore/core/StorageConnection)`<T>` | [createConnection](https://developer.android.com/reference/kotlin/androidx/datastore/core/Storage#createConnection())`()` Creates a storage connection which allows reading and writing to the underlying storage. | Cmn |

## Public functions

### createConnection

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

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

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

Should be closed after usage.  

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