Nice explanation… and I loved the part of the PersistentList, even when it wasn’t the scope of the tutorial, you nailed it with that explanation. Hope you can make a tutorial migrating from shared preferences to proto datastore. Thanks phillip
In common situations where you just need to save a few app settings, Data Store implemented this way is Ok. The only "thing" with this implementation is that it's killing the performance benefits of protocol buffers. The JSON conversion is slow, kotlin-serialization library is faster than Gson, but, it's still slow, if I'm not mistaken it uses reflection which is expensive. In the case you need to access many registries in short periods of time (perhaps transferring data to/from server) using the serialization library on top of protocol buffers would be a mistake. In other words, protocol Buffers is a faster alternative to JSON so using JSON objects in a protocol buffer would be a performance problem.
Can you make a video on how to actually use the protobuf files? I'm going to use the method you are showcasing for the time being because the alternative was too difficult for me
Hmm.. I also have error: kotlinx.serialization.SerializationException: Class 'SmallPersistentVector' is not registered for polymorphic serialization in the scope of 'PersistentList'. Mark the base class as 'sealed' or register the serializer explicitly. With the data classes: @Serializable data class ShoppingCart( val productsList: PersistentList = persistentListOf() ) @Serializable data class ShoppingCartItem( val id: String = "", val size: String = "" )
Struggling with this as well. Seems to be an issue with PersistentList and kotlin immutable collections or even kapt apparently. Have you managed to fix the error?
Thanks for the tutorial. Great explanation and practical implementation. I'm about to start Android soon but I've been using Kotlin for the server-side using Ktor. It's been great...
Error occured: kotlinx.serialization.SerializationException: Class 'SmallPersistentVector' is not registered for polymorphic serialization in the scope of 'PersistentList'.
Could you do a quick vid on using datastore in a viewmodel? I'm trying to apply this video to using it in a viewmodel but failing. I can't use the dataStore in the viewmodel after I create it.
In wich package should i create the AppSettings and AppSetting Serializer in a MVVM project? Actually I created both clasess in my domain layer and use it throught my viewModel. Is that ok?
Hello guys, I'm trying to play it around and my code looks like this private suspend fun setLanguage(language: Language) { dataStore.updateData { it.copy( language = language, knownLocations = it.knownLocations.mutate { locationList -> locationList.add(Location(lat = 12345678.600, lng = 25664125.641)) }) } } is there anyone here try to save the list of Location and got an error like "kotlinx.serialization.SerializationException: Class 'SmallPersistentVector' is not registered for polymorphic serialization in the scope of 'PersistentList'. Mark the base class as 'sealed' or register the serializer explicitly." How can I soleve this error, Thank you in advance
Nice explanation… and I loved the part of the PersistentList, even when it wasn’t the scope of the tutorial, you nailed it with that explanation. Hope you can make a tutorial migrating from shared preferences to proto datastore. Thanks phillip
can you please make a specific video about sockets plz
In common situations where you just need to save a few app settings, Data Store implemented this way is Ok. The only "thing" with this implementation is that it's killing the performance benefits of protocol buffers. The JSON conversion is slow, kotlin-serialization library is faster than Gson, but, it's still slow, if I'm not mistaken it uses reflection which is expensive. In the case you need to access many registries in short periods of time (perhaps transferring data to/from server) using the serialization library on top of protocol buffers would be a mistake. In other words, protocol Buffers is a faster alternative to JSON so using JSON objects in a protocol buffer would be a performance problem.
Can you make a video on how to actually use the protobuf files? I'm going to use the method you are showcasing for the time being because the alternative was too difficult for me
Hmm.. I also have error:
kotlinx.serialization.SerializationException: Class 'SmallPersistentVector' is not registered for polymorphic serialization in the scope of 'PersistentList'.
Mark the base class as 'sealed' or register the serializer explicitly.
With the data classes:
@Serializable
data class ShoppingCart(
val productsList: PersistentList = persistentListOf()
)
@Serializable
data class ShoppingCartItem(
val id: String = "",
val size: String = ""
)
Struggling with this as well. Seems to be an issue with PersistentList and kotlin immutable collections or even kapt apparently. Have you managed to fix the error?
Same problem here, did you find a solution?
Typically local storage is behind a repository/data layer. I wonder if there's a clean yet convenient way to do this.
Belated happy birthday sir
Awesome. I was able to follow along, except I added a few Strings to mine as well. Username, User Email, and Language
I didnt try to do anything with a list yet though
Thanks for the tutorial. Great explanation and practical implementation. I'm about to start Android soon but I've been using Kotlin for the server-side using Ktor. It's been great...
How to handle data migration if we add new or modify the properties in AppSettings?
Error occured: kotlinx.serialization.SerializationException: Class 'SmallPersistentVector' is not registered for polymorphic serialization in the scope of 'PersistentList'.
yes me too
try using a mutableList instead of the persistentList
Thanks for another great tutorial.
Philipp can you please make video on How to learn android development in kotlin from start Im really confused
probably
im also confused
check through his channel, there is a ton of tutorials on that
Nice video, How can I get access to the dataStore into a viewModel class or other class. Thanks
Thanks for explaining. would this work with parcelables classes?
I stumbled upon this - nice video, but how does this work with Hilt?
Thanks, I can store user data in my app now
Could you do a quick vid on using datastore in a viewmodel? I'm trying to apply this video to using it in a viewmodel but failing. I can't use the dataStore in the viewmodel after I create it.
Great tutorial💚
In wich package should i create the AppSettings and AppSetting Serializer in a MVVM project? Actually I created both clasess in my domain layer and use it throught my viewModel. Is that ok?
Thankseveryone
I have a settings screen layout composable how can i access it from this it does not show up do i really need to create from activities
Great Video!
how do we reset the dataStore key values? Do we just reset them to the default values? Is there a one-line method for this
Why not just use room database, I've always wondered 🤔
I think creating and accessing database is more resource expensive
@@divid3d806 That makes sense, thanks for clarifying 👍
What the theme you are using in android studio please?
hey , did you really test adding item into knownLocations? it dose not work since its not workig with list of object when serializing
Is there any way to use it alongside the dagger hilt?
what is difference between proto datastore and Room database
We can write and read, but how to remove it from local storage
how do you serialize PersistentList in moshi?
how would you inject this datastore with hilt?
very cool thank you bro 👍👍👍
I loved when Siri suddenly appeared😂
Nice!!
Does updateData uses Dispatchers.IO by defult?
thanks
Great brother
What is the point of if u gonna convert to string and save it anyway? I dont see the use of proto buffs being here.
Type safety in preferences
@@PhilippLackner where is the fun though?😂
Siri cracked me up XD
Hello guys,
I'm trying to play it around and my code looks like this
private suspend fun setLanguage(language: Language) {
dataStore.updateData {
it.copy(
language = language,
knownLocations = it.knownLocations.mutate { locationList ->
locationList.add(Location(lat = 12345678.600, lng = 25664125.641))
})
}
}
is there anyone here try to save the list of Location and got an error like "kotlinx.serialization.SerializationException: Class 'SmallPersistentVector' is not registered for polymorphic serialization in the scope of 'PersistentList'.
Mark the base class as 'sealed' or register the serializer explicitly."
How can I soleve this error, Thank you in advance