ObjectBoxLiveData
, a class that can be used inside your ViewModel classes.ObjectBoxLiveData
that is constructed using a regular ObjectBox query:getNoteLiveData()
. Instead you could use AndroidViewModel
, which provides access to the Application
context, and then call ((App)getApplication()).getBoxStore().boxFor()
inside the ViewModel. However, the first approach has the advantage that our ViewModel has no reference to Android classes. This makes it easier to unit test.