truu. I have never wanted to rip my hair out. I stopped halfway because I kinda realized, the guide was intended for people migrating from sharedPreferences
In version 1.0.0 (stable version): Instead of: val dataStoreKey = preferencesKey(key) Use the code below in save and read functions: val dataStoreKey = stringPreferencesKey(key)
Thank you again! This will be very useful for me very soon. And I have some feedback for you :) The way you make your video are pretty good, and I think it would be even better if you include a brief section at the start of the video (maybe after the demo) where you talk about the big steps like an overview. For example: 1. Add dependencies. 2. Create Datastore object. 3. Create function to save data. 4. Create function to read data. 5. Calling the functions from buttons. 6. ... For me this kind of overview helps me follow better because I know where we're at an where we're going next, especially when it's something new. If I have no idea of the big steps I tend to wonder: So are we done with the object creation? Ah not yet. Done yet? Not yet. Is this the last variable that we need? Nope we need one more, no actually one more... (I get distracted like this) This is my personal feedback for you to add to others' feedback and see what suits best for your audience as a whole :) I hope your channel grows even more as days pass, keep up the good work, I'll always support you for the efforts you put in these contents. Thank you!
Thanks for the video, useful stuff as always! Also, and I don't want to sound like a smart-ass, but I think we only need to nullify the binding variable in fragments (since only fragments have different lifecycles for their instance and their view, which causes the memory leak in the first place).
For anyone wondering that would be: // At the top level of your kotlin file: val Context.dataStore: DataStore by preferencesDataStore(name = "settings")
The old sharedpreferences is deprecated not the androidx version. Don't go down this DataStore track if you are still planning to use the Preferences screens because they are not compatible, no one mentions this. In the docs, sharedpreferences are still recommended for its traditional use case and has the advantage many advantages.
Firebase, Android, GCP .... HORRIFIC DOCS! Google knows how to measure impact of everything they do out there except their docs. It's a shithousery award for Google.
Hey in new library I am not able to import preferencesKey with this version implementation "androidx.datastore:datastore-preferences-core:1.0.0-alpha06"
Nice video. I have question how to remove value of the specific key or how to clear whole datastore value like we used to do in shared preference by calling clear()
To anyone watching this video and wishing to add Preferences DataStore to your application. Please note that you should add exception handling before releasing this code into production. The code in this video is not production ready and should be treated accordingly
Thanks a lot man! As always very clear and constructed tutorial. Can you also create a video about using dataStore in Java for login session (storing user acount details)?
What if we want to read from the data store on a settings screen without providing default values for the switches (I want the switches to be on as soon as the screen comes up, but if I set the stateFlow to lateinit, I will get an error because by the time View model is created, the coroutine hasn't finished executing yet)?
I want to make a questionnaire styled app. Where there are lets say 5 multiple choice questions. And depending what choice it itll be different prices of something. So like a very basic bare bones version of a shopping cart. Would this be the method to go with? I have a photography business and I want to add up everything at the end and display it to the user.
Hello, Philipp Lacner I got question, if you could answer it that would be very helpful. so, in new API version there would be changes and some codes might be deprecated as you mentioned, but when we are developing new app we must make sure the app should run on older Android versions, so if we use latest technology(code), would it run on older APIs. even though when code deprecated it still works. right? both on older and latest APIs
Wow thanks.. I need help.. I have User model, and want it to save in DataStore with data type as User. So when I read DataStore, I get User data. Any efficient idea how to do it? Thank you
@Philipp Lackner Could we get something on MediaStore API, like how retrieve all photos on an Android device and plug it into a ML Recognition service.
Dear , My question is reading data from datastore using lifecycleScope is safe. It may causes ANR(Application not responding). Pls make video on how ANR occur on fetching data from datastore
Hi and thanks for the great videos you share with us. I have a problem using Datastore.. everything works perfect until trying to open fragment for second time. Then i get error There are multiple DataStores active for the same file: ..... You should either maintain your DataStore as a singleton or confirm that there is no two DataStore's active on the same file (by confirming that the scope is cancelled). Stucked and don't know what to do to fix this... Can you give a little help?
Nice video., I have a question,.how to return a value from lifecyclescope.launch . This value we will get inside this launch and I want to return this in another function.
Hii can u make the video on how to pass data in nested graph in fragments . Let's say Graph1 has fragment A,B,C,D Fragment B contain a graph having fragment P,Q,R,S. So I need to pass model from fragment B to any fragment P,Q,R,S As per needs Plz give me solutions thanks
This was actually a lot easier to follow than the official CodeLab for DataStore Preferences. They were leading on a goose chase of using repositories
Yep
truu. I have never wanted to rip my hair out. I stopped halfway because I kinda realized, the guide was intended for people migrating from sharedPreferences
In version 1.0.0 (stable version):
Instead of:
val dataStoreKey = preferencesKey(key)
Use the code below in save and read functions:
val dataStoreKey = stringPreferencesKey(key)
Love u man..
U just upload videos exactly what I'm missing or want to learn and without asking you...
Your choice of video topic is on point..
Thank you, what else you want to learn? I'm always open for new ideas. Would be cool if it fits in a 10-20min video
@@PhilippLackner Jetpack compose
@@PhilippLackner a dedicated video on api calls and image processing.
@@AyushSachan2211 yes please
@@PhilippLackner Work Manager
I like these short videos.
+1
short videos are more descriptive :)
Thank you!
+1
@@xD-saleem yes +1
Thank you again! This will be very useful for me very soon. And I have some feedback for you :)
The way you make your video are pretty good, and I think it would be even better if you include a brief section at the start of the video (maybe after the demo) where you talk about the big steps like an overview.
For example:
1. Add dependencies.
2. Create Datastore object.
3. Create function to save data.
4. Create function to read data.
5. Calling the functions from buttons.
6. ...
For me this kind of overview helps me follow better because I know where we're at an where we're going next, especially when it's something new.
If I have no idea of the big steps I tend to wonder:
So are we done with the object creation? Ah not yet.
Done yet? Not yet.
Is this the last variable that we need?
Nope we need one more, no actually one more...
(I get distracted like this)
This is my personal feedback for you to add to others' feedback and see what suits best for your audience as a whole :)
I hope your channel grows even more as days pass, keep up the good work, I'll always support you for the efforts you put in these contents. Thank you!
plz make a playlist on jetpack architecture components!!!
Thanks for the video, useful stuff as always!
Also, and I don't want to sound like a smart-ass, but I think we only need to nullify the binding variable in fragments (since only fragments have different lifecycles for their instance and their view, which causes the memory leak in the first place).
ah you're totally right, I just got used to that since I mostly do my stuff in fragments. Thanks!
Thank you for the valued reminder
Really Thankful to you Philip
Everyday before I sleep I make sure I see one of your videos
Thanks!
Hello, I was a bit confused..... the function createDataStore has been removed as of the Stable release of DataStore.
In version 1.0.0-alpha07 the Context.createDataStore extension function has been removed and replaced with globalDataStore property delegate.
For anyone wondering that would be:
// At the top level of your kotlin file:
val Context.dataStore: DataStore by preferencesDataStore(name = "settings")
The old sharedpreferences is deprecated not the androidx version. Don't go down this DataStore track if you are still planning to use the Preferences screens because they are not compatible, no one mentions this. In the docs, sharedpreferences are still recommended for its traditional use case and has the advantage many advantages.
Well, I am also confused with deprecated statement. There are no even article or something related to migrate preference screen to datastore.
I was hoping to find a datastore tutorial by PL. 😊
you're the best philipp
Thanks for this! The official CodeLab was way too complicated for me to follow
Firebase, Android, GCP .... HORRIFIC DOCS!
Google knows how to measure impact of everything they do out there except their docs. It's a shithousery award for Google.
Thanks man 👍🏻
You're a gem 💎
Hey in new library I am not able to import
preferencesKey
with this version
implementation "androidx.datastore:datastore-preferences-core:1.0.0-alpha06"
Please make an updated video on shared preferences for complex tasks
Nice video. I have question how to remove value of the specific key or how to clear whole datastore value like we used to do in shared preference by calling clear()
And to remove a spceific key only, use
val dataStoreKey = preferencesKey(key)
dataStore.edit{
it.remove(dataStoreKey)
}
@@KaiqueOcanhasdds dos teus vídeos kkk
@@fernandobsep vlww Man. Sdds tbm, mas a saúde cobrou. Quero voltar ainda
To anyone watching this video and wishing to add Preferences DataStore to your application. Please note that you should add exception handling before releasing this code into production. The code in this video is not production ready and should be treated accordingly
Awesome mentor 🙏
Thanks a lot man! As always very clear and constructed tutorial. Can you also create a video about using dataStore in Java for login session (storing user acount details)?
im looking for the same
What if we want to read from the data store on a settings screen without providing default values for the switches (I want the switches to be on as soon as the screen comes up, but if I set the stateFlow to lateinit, I will get an error because by the time View model is created, the coroutine hasn't finished executing yet)?
thanks another awesome course
how about datastore in livedata(viewmodel)
i already created my own version though i'm not sure if that is correct.
Another great video!
Thanks again!
Thanx man this was very helpful 😊
Thanks a lot for this video.
You are most welcome
Hey @philip the save and read are async so before reading we should ensure that save is finished right.?
I want to make a questionnaire styled app. Where there are lets say 5 multiple choice questions. And depending what choice it itll be different prices of something. So like a very basic bare bones version of a shopping cart.
Would this be the method to go with?
I have a photography business and I want to add up everything at the end and display it to the user.
How is you update UI from background launch???
Thanks. Please make a video about MVI architecture. Can't find good explanation of that with a simple example :(
ua-cam.com/video/8vAQrgbh6YM/v-deo.html
Hello, Philipp Lacner
I got question, if you could answer it that would be very helpful.
so, in new API version there would be changes and some codes might be deprecated as you mentioned, but when we are developing new app we must make sure the app should run on older Android versions, so if we use latest technology(code), would it run on older APIs.
even though when code deprecated it still works. right? both on older and latest APIs
Thanks for the good video, in a bit large project don't we need to create datastore as a Singltone object ?
Very interested video!
Glad you enjoyed it
Helpful video , thank you so much , but there is also prototypes , are you making any videos about that ?
wow didn't know sharedpreferences going to be deprecated
Wow thanks..
I need help..
I have User model, and want it to save in DataStore with data type as User. So when I read DataStore, I get User data. Any efficient idea how to do it? Thank you
@Philipp Lackner Could we get something on MediaStore API, like how retrieve all photos on an Android device and plug it into a ML Recognition service.
How to retrieve data from DataStore preference to using in OkHttp Interceptor with Dagger Hilt?
Hey philipp when using a fragment with viewBinding do you really need to set it to null in onDestroy callback?
Yeah it seems. To prevent memory leaks, I believe so.
Actually in activity you don't need to set it to null. This is for fragments.
@@haykmkrtchyan7093 Ahh sorry, I actually meant for fragments too. Didn't realize the "activity" there. Thanks btw 😁
@@prasanthmanimaran5158 Welcome 😁
@@haykmkrtchyan7093 yeah sure
Thank you man
Hi, do you have any videos for networking and database caching
Dear , My question is reading data from datastore using lifecycleScope is safe. It may causes ANR(Application not responding). Pls make video on how ANR occur on fetching data from datastore
Thanks. It was very clear. But can we save Lists/Arrays via Preference DataStore?
you could, but you better use a database for that
Hi and thanks for the great videos you share with us. I have a problem using Datastore.. everything works perfect until trying to open fragment for second time. Then i get error
There are multiple DataStores active for the same file: ..... You should either maintain your DataStore as a singleton or confirm that there is no two DataStore's active on the same file (by confirming that the scope is cancelled). Stucked and don't know what to do to fix this... Can you give a little help?
What is the secure way to store JWT token on android ?
wow video. Please make video on video streaming and custom view.
dhanyawaad chacha
abe angrez hai woh ...lol
@@akashdeepwadhwa5828 pta hai bhai🙂
hello
please make it possible to pay in digital currency to purchase courses.
How can I use it in settings fragment?
I listened we can save class of arrayList before
Can I !?
If you think he's clickbaiting by writing "deprecated", don't forget that once he deprecated his channel name as well. 😂😂
This time it's really deprecated :D
Nice video., I have a question,.how to return a value from lifecyclescope.launch . This value we will get inside this launch and I want to return this in another function.
use async instead of launch. Then you get the value with .await()
@@PhilippLackner okay. Thanks. Any code snippet do you have for this ? It will be helpful. Actually I tried that didn't work..
Thanks
How to secure this?
still using SharedPreferences :( but since this video is uploaded will switch to dataStore with DI :)
thanks you
Good tut , and Friday is not black its white.
Shouldn't we specify IO Dispatchers?
datastore switches to IO dispatcher behind the scenes
Thanks :D
Thanks :)
Welcome!
its 2023 i dont know sharedpref were deprecated
You had beard? 😂😂😂
Way not simple? Complicated Android remaking the road. createDataStore not isn't found for me.
6.6 min with 1.5 time speed 😝
That's cheating
Hii can u make the video on how to pass data in nested graph in fragments .
Let's say Graph1 has fragment A,B,C,D
Fragment B contain a graph having fragment P,Q,R,S.
So I need to pass model from fragment B to any fragment P,Q,R,S
As per needs
Plz give me solutions thanks
save shared pref to database ? hahahah
why i need shared pref if saved user info to database
nice smart video 🦥