Aug 9, 2017 · 1 min read
There is something worth mentioning about ViewModels that as yet, appears to be undocumented. This just caused me hours of headaches and stepping through the source code to figure out.
ViewModels use Fragments to retain their data. If like I did, you expect only YOUR fragments to be in the FragmentManager so think nothing of clearing them all out, beware because you are also clearing the previously created ViewModels.
Never clear any fragments with an instanceOf “android.arch.lifecycle.HolderFragment”