I have been trying to create an Object of ViewModel in an Activity but ViewModelProviders is deprecated So what\'s the alternative to create the ViewModel\'s object.
This class is deprecated. Use the constructors for ViewModelProvider directly. here
So instead of using this
ViewModelProviders.of(this).get(MyViewModel.class); - deprecated
Use this one
new ViewModelProvider(this).get(MyViewModel.class); - correct