PreferencesSerializer



Proto based serializer for Preferences. Can be used to manually create DataStore using the DataStoreFactory#create function.

Summary

Public functions

open suspend Preferences

Unmarshal object from source.

Cmn
android
N
open suspend Unit

Marshal object to a Sink.

Cmn
android
N

Public properties

open Preferences

Value to return if there is no data on disk.

Cmn
android
N

Public functions

readFrom

open suspend fun readFrom(source: BufferedSource): Preferences

Unmarshal object from source.

Parameters
source: BufferedSource

the BufferedSource with the data to deserialize

Throws
androidx.datastore.core.CorruptionException

if the data from input is corrupted and/or unparseable, e.g. InvalidProtocolBufferException when the type T is a protobuf message and it is corrupted. Other unrecoverable IOException from the file system should not be thrown as CorruptionException.

writeTo

open suspend fun writeTo(t: Preferences, sink: BufferedSink): Unit

Marshal object to a Sink.

Parameters
t: Preferences

the data to write to output

sink: BufferedSink

the BufferedSink to serialize data to

Public properties

defaultValue

open val defaultValuePreferences

Value to return if there is no data on disk.