androidx.datastore.core
Interfaces
Closeable |
Datastore common version of java.io.Closeable |
Cmn
|
CorruptionHandler |
CorruptionHandlers allow recovery from corruption that prevents reading data from the file (as indicated by a CorruptionException). |
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 |
Cmn
|
StorageConnection |
StorageConnection provides a way to read and write a particular type |
Cmn
|
WriteScope |
The scope used for a write transaction. |
Cmn
|
Classes
FileStorage |
The Java IO File version of the Storage |
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
JS
|
Objects
DataStoreFactory |
Public factory for creating DataStore instances. |
Cmn
android
N
JS
|
MultiProcessDataStoreFactory |
android
|
Type aliases
IOException |
Common IOException mapped to java.io.Exception in jvm code. |
android
|
Top-level functions summary
InterProcessCoordinator |
createMultiProcessCoordinator(context: CoroutineContext, file: File)Create a coordinator for multiple process use cases. |
android
|
InterProcessCoordinator |
Create a coordinator for single process use cases. |
android
|
Extension functions summary
File |
@RequiresApi(value = 24)Generate the File object for DataStore for use during direct boot. |
android
|
suspend T |
<T : Any?> StorageConnection<T>.readData() |
Cmn
|
inline 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 |
file: File |
the File in which |
createSingleProcessCoordinator
fun createSingleProcessCoordinator(file: File): InterProcessCoordinator
Create a coordinator for single process use cases.
| Parameters | |
|---|---|
file: File |
The canonical file managed by |
Extension functions
deviceProtectedDataStoreFile
@RequiresApi(value = 24)
fun Context.deviceProtectedDataStoreFile(fileName: String): File
Generate the File object for DataStore for use during direct boot. If the provided context is a user encrypted context, it is converted to a DeviceProtectedStorageContext via Context.createDeviceProtectedStorageContext.
The file is generated by calling File(deviceProtectedContext.filesDir, "datastore/$fileName").
Do NOT use the file outside of DataStore.
The context used to get the files directory @fileName the file name
use
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. |