androidx.datastore.core

Interfaces

Closeable

Datastore common version of java.io.Closeable

Cmn
DataMigration

Interface for migrations to DataStore.

Cmn
DataStore

DataStore provides a safe and durable way to store small amounts of data, such as preferences and application state.

Cmn
InterProcessCoordinator

InterProcessCoordinator provides functionalities that support DataStore instances to coordinate the concurrent work running on multiple threads and multiple processes to guarantee its data consistency.

Cmn
ReadScope

The scope used for a read transaction.

Cmn
Serializer

The serializer determines the on-disk format and API for accessing it.

android
Storage

Storage provides a way to create StorageConnections that allow read and write a particular type of data.

Cmn
StorageConnection

StorageConnection provides a way to read and write a particular type of data.

Cmn
WriteScope

The scope used for a write transaction.

Cmn

Classes

FileStorage

The Java IO File version of the Storage interface.

android

Exceptions

CorruptionException

A subclass of IOException that indicates that the file could not be de-serialized due to data format corruption.

Cmn
IOException

Common IOException to be defined in jvm and native code.

Cmn
android
N

Objects

Type aliases

IOException

Common IOException mapped to java.io.Exception in jvm code.

android

Top-level functions summary

InterProcessCoordinator

Create a coordinator for multiple process use cases.

android
InterProcessCoordinator

Create a coordinator for single process use cases.

android

Extension functions summary

suspend T
Cmn
inline R
<T : Closeable, R : Any?> T.use(block: (T) -> R)

Ensures a Closeable object has its close() method called at the end of the supplied block.

Cmn
suspend Unit
<T : Any?> StorageConnection<T>.writeData(value: T)
Cmn

Top-level functions

createMultiProcessCoordinator

fun createMultiProcessCoordinator(context: CoroutineContext, file: File): InterProcessCoordinator

Create a coordinator for multiple process use cases.

Parameters
context: CoroutineContext

the coroutine context to be used by the MultiProcessCoordinator for IO operations.

file: File

the File in which DataStore stores the data.

createSingleProcessCoordinator

fun createSingleProcessCoordinator(file: File): InterProcessCoordinator

Create a coordinator for single process use cases.

Parameters
file: File

The canonical file managed by SingleProcessCoordinator

Extension functions

suspend fun <T : Any?> StorageConnection<T>.readData(): T
inline fun <T : Closeable, R : Any?> T.use(block: (T) -> R): R

Ensures a Closeable object has its close() method called at the end of the supplied block.

Throws
kotlin.Throwable

any exceptions thrown in the block will propagate through this method.

suspend fun <T : Any?> StorageConnection<T>.writeData(value: T): Unit