Reputation: 7603
I have an Android ViewModel
class MyVM: ViewModel()
In my activity, I can create an instance of MyVM
using either:
val viewModel = MyVM()
or using:
val viewModel = ViewModelProvider(this).get(MyVM::class.java)
They both work as expected. My question is what are the main differences between the two
Upvotes: 0
Views: 210