Hello… If you already have “room” added as depende...
# android
p
Hello… If you already have “room” added as dependency and are using it across app, is it worth migrating to Datastore to save key-value pairs? It is just one table in my database “vs” one extra dependency and more learning curve as everyone is already familiar to room, and the room setup is hardly 30 lines for that extra table. Even room has “suspend” support and other things.
not kotlin but kotlin colored 2
a
Based on this article, datastore is aimed to replace sharedpreferences, not Room database
p
Yes but just that would u use it if u already had a working room setup for key value pair?
f
room and datastore serve different purposes, not using the right tool now will only lead to pain in the future
p
I have been using SQDelight to save key/value pairs in multiplatform projects. It's been good so far.
f
yes, that's the same as saying "I've been using my hammer to insert my screws, it's been good so far"
p
Anything in particular Francesc, what could make the difference? Or what advantages could have one approach over the other?
f
it's just a matter of using the right tool for the right job. Datastore is meant for small set of key/value pairs (or small data objects with protobuf), while Room or SQLDelight are relational databases that serve different purposes, they can handle large data sets, filtering, and much more. While you can use Room to store your key/value pairs, it's just not the right tool for the job, datastore has been optimized for this kind of persistent storage and is a fetter fit
👍🏻 1
👍 1
p
Gotcha, makes sense