Android ViewModel doesn't survive fragment change
Try binding to the activity instead of the current fragment.
interventionViewModel = ViewModelProviders.of(activity).get(InterventionsViewModel.class);
Since the ViewModelProviders
class is deprecated the correct way is to use ViewModelProvider
and let the ViewModel survive the fragments life-cycle by binding it to the activities life-cycle by using
requireActivity()
as documented by Google here:
model = new ViewModelProvider(requireActivity()).get(SharedViewModel.class);