CorruptionHandlers allow recovery from corruption that prevents reading data from the file (as indicated by a CorruptionException).
Interface for migrations to DataStore.
DataStore provides a safe and durable way to store small amounts of data, such as preferences and application state.
The serializer determines the on-disk format and API for accessing it.
A subclass of IOException that indicates that the file could not be de-serialized due to data format corruption.
Extension functions summary
Create an instance of SingleProcessDataStore.
fun <T> Context.createDataStore(
corruptionHandler: ReplaceFileCorruptionHandler<T>? = null,
migrations: List<DataMigration<T>> = listOf(),
scope: CoroutineScope = CoroutineScope(Dispatchers.IO + SupervisorJob())
Create an instance of SingleProcessDataStore. The user is responsible for ensuring that there is never more than one instance of SingleProcessDataStore acting on a file at a time.
|fileName: String||the filename relative to Context.filesDir that DataStore acts on. The File is obtained by calling File(context.filesDir, fileName). No two instances of DataStore should act on the same file at the same time.|
|corruptionHandler: ReplaceFileCorruptionHandler<T>? = null||The corruptionHandler is invoked if DataStore encounters a CorruptionException when attempting to read data. CorruptionExceptions are thrown by serializers when data can not be de-serialized.|
|migrations: List<DataMigration<T>> = listOf()||are run before any access to data can occur. Each producer and migration may be run more than once whether or not it already succeeded (potentially because another migration failed or a write to disk failed.)|
|scope: CoroutineScope = CoroutineScope(Dispatchers.IO + SupervisorJob())||The scope in which IO operations and transform functions will execute.|