Android ViewModel additional arguments

You need to have a factory class for your ViewModel. public class MyViewModelFactory implements ViewModelProvider.Factory { private Application mApplication; private String mParam; public MyViewModelFactory(Application application, String param) { mApplication = application; mParam = param; } @Override public <T extends ViewModel> T create(Class<T> modelClass) { return (T) new MyViewModel(mApplication, mParam); } } And when instantiating the … Read more

AndroidViewModel vs ViewModel

AndroidViewModel provides Application context If you need to use context inside your Viewmodel you should use AndroidViewModel (AVM), because it contains the application context. To retrieve the context call getApplication(), otherwise use the regular ViewModel (VM). AndroidViewModel has application context. We all know having static context instance is evil as it can cause memory leaks!! … Read more

What is ViewModel in MVC?

A view model represents the data that you want to display on your view/page, whether it be used for static text or for input values (like textboxes and dropdown lists) that can be added to the database (or edited). It is something different than your domain model. It is a model for the view. Let … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)