Shared ViewModel - Explained | Android Studio Tutorial

preview_player
Показать описание
🏆 My Online Courses
⭐Discount Coupon: LAUNCH-STEVDZA-SAN

🐱‍👤 Wanna become a member? Join!

📸 Instagram

So far you might got used on having a single ViewModel instance per Fragment? So when you regularly instantiate one ViewModel in your Fragment, it's often scoped to a lifecycle of your Fragment, right? And by scoping that one ViewModel to a single Fragment you cannot share values between multiple Fragments. Which make sense.

In order to Share values from the same ViewModel instance between
multiple Fragments, you need to scope ViewModel to an Activity instead. Watch the video to learn more about it.

🕒 Timestamps:
0:00 - Introduction
2:08 - About the project
2:46 - Create Shared ViewModel
4:50 - Let's Start
Рекомендации по теме
Комментарии
Автор

I just want to tell you that you saved me from further stress today. Been having a problem with a parent fragment and its child fragment that are supposed to share one viewmodel. The key was "activityViewModels". Thanks for explaining what it's for!

toncatzu
Автор

Sir thank you so much !! Clear explanation Lot's of love from India ❤

bharathprakash
Автор

Thank you! Simple, straight to the point, and now I have a great understanding as to how to share data between fragments tied to the same activity.

tylerryden
Автор

Smart content and creative animations ❤️. We're still waiting for the Jetpack Compose 🚀 series.

ericgacoki
Автор

Nice. Easy to understand, and well explain too

herisarwanto
Автор

Very precisely explained. Thanks a lot for this. ❤️ From India

AmitJayant
Автор

U have the best profile picture ever 🤣, Also thx for the Great videos

nima
Автор

Just what i needed and explianed in a clear way

irvingj.villanueva
Автор

Man!!! I was running crazy after this! You explained well you showed an example well! you just earned a sub <3

dumbxyz
Автор

Thanks man, I am learning android development, and I am working on a project which uses the concepts of navigation. I wanted to retrieve data from 1st Fragment. I tried everything like I tried data Classes to save data from 1st Fragment and use it in the 2nd Fragment but it did'nt work. Then, I realized that there must be another way of communication between two Fragments. Thank You very much for this information.

mwahajsajidali
Автор

Thank you man. I was having trouble navigating between fragments as my viewmodel was scoped to fragments instead of the activity.

kamandemwangi
Автор

Stevzda, thank you so much, man. Your tutorials are just so on point.

mobbs
Автор

No words for your tutorial . u hit the bull eye

tadiyal
Автор

Very simple and giving good inspiration thanks for well education

batuhans.
Автор

please make a video about shared viewmodel with nested navgraphs. there are no tutorials about it

Revitalish
Автор

I like how you deliver your content. It's well understood. Thanks

samuelwakoli
Автор

Thank you. Explanation was very clear.

subindsuresh
Автор

Great video and example .. my fav one by you!

iftak
Автор

Amazing I always waiting for you vedio

easybusinessou
Автор

Can you please do a video on how we could save the recycler view scroll positions used in fragments using the shared shared ViewModel... As of now I m hiding and showing fragments while navigating which is not an elegant solution

anudeepananth
join shbcf.ru