168 questions
0
votes
1
answer
96
views
How to speed up DataStore reads in a Kotlin Multiplatform (KMP) project?
I’m using Jetpack DataStore (Preferences) in a Kotlin Multiplatform Mobile (KMM/KMP) project to store some user data, including a JSON-serialized object:
class DataStoreVM(
private val dataStore: ...
0
votes
1
answer
105
views
Android Jetpack DataStore throws java.lang.NoClassDefFoundError for proto.ListOfStrings only in instrumentation tests
I have swapped SharedPreferences for DataStore in a common module in my Android app. I use DataProperty for easy access to the parameters and and interface MyDataStore injected on need. Because of the ...
0
votes
0
answers
54
views
Memory leak when collecting DataStore<Preference> as state in ComposeView overlay
I'm developing a foreground service to display an overlay view.
The service uses a ComposeView whose content depends on the data of a Preference DataStore.
The content of the ComposeView looks like:
//...
2
votes
0
answers
80
views
Proper way to share app settings state across all screens in Jetpack Compose: CompositionLocal
I’m developing a water-tracking app where a setting like volumeUnit (mL/L) needs to be accessible across almost all screens. I’ve implemented a SettingsManager (using DataStore) and a ...
0
votes
1
answer
103
views
Cannot access class 'androidx.datastore.preferences.core.Preferences.Key in JVM
in this code:
fun getString(key: Preferences.Key<String>, default: String = ""): Flow<String> {
return preferences.data.map { value ->
value[key] ?: ...
1
vote
2
answers
320
views
Pattern to access kotlin DataStore values without using suspend functions
I am using a class to store and load data from a DataStore in my kotlin multiplatform app. The class is simple:
class AuthPersistence(
private val context: Context
) {
private val Context....
8
votes
2
answers
683
views
KMP Compose Multiplatform Datastore not working on JVM release build
I am working on a Kotlin Multiplatform / Compose Multiplatform app with Android and Desktop as targets. I wanted to use DataStore to store some data locally, namely the user's refresh token and some ...
0
votes
1
answer
89
views
DataStore access stops function execution
I am trying to persist some simple state of my android app using preferences with Jetpack DataStore. I want to fill the value of a key with a default value if there was nothing stored yet. However ...
1
vote
0
answers
86
views
How to play sound from Glance widget using MediaSessionService
I'm trying to write an app that allows audio to be launched from an app and widget using Jetpack Compose and Glance Widgets. The app shows all audio from the device, which can be controlled (start and ...
2
votes
1
answer
164
views
How do you stop a value saved in Preferences Datastore from resetting when the app is relaunched?
Whenever I relaunch an app, values that are saved in Preferences Datastore are reset.
In particular, I'm trying to save whether the user selected light mode or dark mode for their preferred background ...
0
votes
2
answers
258
views
How to init TextField with datastore variable
Having a composable which has a textfield which needs to work with a by remember mutablestateof String called text, that variable must be initialized with a datastore stored value. I have the ...
1
vote
2
answers
307
views
About Collecting Values from DataStore
I'm currently using DataStore to store and collect values to create a UI.
There are flows for collecting Volume and Media Path.
I understand that when I store a value, it should be collectable in the ...
4
votes
1
answer
391
views
Intrumentation test using androidx.datastore version 1.1.1 now fails with UncompletedCoroutinesError
I updated these implementations in app/build.gradle from 1.0.0 to 1.1.1:
implementation "androidx.datastore:datastore-preferences:$androidXDatastore"
implementation "androidx.datastore:...
0
votes
2
answers
660
views
Global DataStore instance. Kotlin
I want to store an access token in the DataStore when it is received. As such i created a class(DataStore) that handles the getting,saving and clearing. Since I want the same instance of DataStore to ...
0
votes
1
answer
60
views
Variable doesn't seem to change after assigning a number to it
I am attempting to get the number of lives into the quiz. What seems to happen is that the number of lives from the preferences datastore is stored into the variable, yet when it comes to actually ...
1
vote
1
answer
307
views
Android Jetpack DataStore value is not null the first time the app is opened
When using a specific name for the DataStore ("settings" in this case), the Preference value is not null the first time I open the app. But if I change the DataStore name to something ...
0
votes
1
answer
418
views
Retrieving data from DataStore using runBlocking
Would it be a good approach to use runBlocking in following implementation? Would it cause UI to be laggy?
I use it all in my viewModel.
lateinit var centralReturnsPaging: Flow<PagingData<...
1
vote
1
answer
267
views
Jetpack Compose theme switching UI glitch at startup Android 12
I'm working on an android app in which I have to implement a "hot" theme switching functionality based on a user choice.
I started with this article implementing a slight different approach, ...
0
votes
1
answer
188
views
Jetpack Datastore: how can I test that my IOException handling is working correctly?
WE have a solution in which we have a few data points that are stored in a Perferences Datastore. We realised that we had failed to account for the IOException correctly, and made a fix.
For peace of ...
0
votes
1
answer
445
views
Android Jetpack DataStore
I want use Jetpack DataStore in my app and according to setup instruction in: https://developer.android.com/topic/libraries/architecture/datastore I have added the following to my build.gradle.kts(:...
0
votes
0
answers
248
views
How to read and save booleans from a repository with DataStore in Jetpack Compose
I have a repository including a list of words which I connected with a unique checkbox. Each time I close the app I want the checkbox value to be saved. So I am using Jetpack DataStore for that.
It ...
0
votes
1
answer
237
views
Where does the one-instance-per-file restriction come from in Jetpack Datastore?
The Jetpack DataStore documentation has rules that you must only create one instance per file or its functionality will be broken.
This seems like a very unusual restriction to me and I have never ...
1
vote
2
answers
679
views
Data Store clean up in unit test error - Only a single call to `runTest` can be performed during one test
Getting the following error,
Only a single call to runTest can be performed during one test.
In-unit tests for data store.
The issue is clearly because I have runTest in @After for data store ...
0
votes
0
answers
529
views
saving data using RxDataStore<Preferences> not working using java android
I want to save data using DataStore, here is my implementation:
android {
namespace 'com.Test'
compileSdk 33
useLibrary 'org.apache.http.legacy'
defaultConfig {
applicationId &...
0
votes
1
answer
1k
views
ISO date string to google.protobuf.Timestamp?
I have an ISO date string like this:
2023-06-13T19:34:35.12345Z
and I need to convert it to an com.google.protobuf.Timestamp to store it in a Proto DataStore.
How can I do that? (I am using Kotlin on ...