https://kotlinlang.org logo
p

pascalchidi

03/09/2021, 5:47 AM
java.io.IOException: at androidx.datastore.core.SingleProcessDataStore.writeData$datastore_core (SingleProcessDataStore.kt:303) at androidx.datastore.core.SingleProcessDataStore.transformAndWrite (SingleProcessDataStore.kt:280) at androidx.datastore.core.SingleProcessDataStore$actor$1.invokeSuspend (SingleProcessDataStore.kt:165) at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith (ContinuationImpl.kt:33) at kotlinx.coroutines.DispatchedTask.run (DispatchedTask.kt:106) at kotlinx.coroutines.scheduling.CoroutineScheduler.runSafely (CoroutineScheduler.kt:571) at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.executeTask (CoroutineScheduler.kt:738) at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.runWorker (CoroutineScheduler.kt:678) at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.run (CoroutineScheduler.kt:665)
l

louiscad

03/09/2021, 2:02 PM
The android issue tracker in the AndroidX Datastor component is probably the best place to ask that.
p

pascalchidi

03/12/2021, 7:22 PM
I figured out that the problem is because am creating multiple instance of my preference class.
How can i stop this.
A singleton class maybe. But how to access context in singleton class.
l

louiscad

03/12/2021, 7:23 PM
appCtx
with Splitties App Context
BTW, there's also a library module in Splitties for type-safe and key-safe SharedPreferences (named Preferences), though I'd recommend using AndroidX Datastore anyday because of performance problems in SharedPreferences in the Android platform that might even lead to ANRs.
p

pascalchidi

03/12/2021, 7:25 PM
Yeah
Thanks. Will have a look.