Category : android-jetpack-datastore

I need to set the name of chosen category, below is the category object code and methods I call by clicking. Grateful for helping. categoryItem object: @Entity(tableName = "category_table") @Parcelize data class CategoryItem( val categoryName: String, val categoryNumber: Int, val categoryShown: Boolean = false, @PrimaryKey(autoGenerate = true) var id: Int = 0 ) : Parcelable ..

Read more

I’m trying to use staticCompositionLocalOf in Jetpack Compose according to this article on Medium. This is my ProvidableCompositionLocal val LocalColors = staticCompositionLocalOf { DarkColorPalette } I have also provided it in my Theme function as shown below. I’m getting the darkTheme from Android DataStore @Composable fun BMICalculatorTheme( darkTheme: Boolean, content: @Composable () -> Unit ) ..

Read more

I want to store some preferences using DataStore. But the problem is that my application can have multiple users and therefor needs to store these preferences in separate files. I got a working example using only one user but I’m struggling to support multiple users. Here is an example of my code: class DataStorageRepository(private val ..

Read more

I try to store & get data using a datastore-preference alpha07, everything working fine, I got some memory leak issue in the datastore What’s the best practice to prevent memory leaks using Datastore? here is my sample code: // Preferences DataStore implementation "androidx.datastore:datastore-preferences:1.0.0-alpha07" // Leakcanary find memory leak debugImplementation ‘com.squareup.leakcanary:leakcanary-android:2.6’ UserManager.kt import androidx.datastore.core.DataStore import androidx.datastore.preferences.core.* ..

Read more

So with the new alpha07 version, Android ditched the private val dataStore = context.createDataStore(name = "settings_pref"), however the new way they use datastore doesn’t work for me. Since upgrading from "androidx.datastore:datastore-core:1.0.0-alpha06" to alpha07, I can’t seem to make my datastore syntax work without getting red-colored code (the error comes when i add context.dataStore.edit). Also downgrading ..

Read more

I’m trying to write unit tests for a part of a code base that’s using the Jetpack’s Datastore library. However, when a unit test calls a method in the code base that creates the Datastore instance, I get the following error: Method threw ‘java.lang.NoClassDefFoundError’ exception. Could not initialize class androidx.datastore.core.DataMigrationInitializer The instantiation of the DataStore ..

Read more

I am building an app that sends the user’s FCM token as an Authorization header to my server for each networking call. (Please correct me if this is a terrible idea as well.) I have it working correctly, in some manner. One exception, I’m using runBlocking{} to get the value from Datastore. I understand this ..

Read more

EDIT: I NEED TO PASS A CONTEXT AS A PARAMETER TO THE CLASS (DataStore and repository is the same class, don’t get confused) I have two activities, A and B and one repository. Activity A opens activity B and activity B saves data in the repository(DataStore a part of android jetpack). I am using LiveData ..

Read more