I am writing a music player. I'm following MVVM
. So the fragmentA
needs a list of songs. This fragment
calls a method in ViewModelClass
that in turn uses a standalone class (implementing LoaderCallbacks
) and returns a list of song. This fragment
can delete a song from the list and it wants to get the new/updated list also. So I have two questions:
1) Should activity
implement loadercallbacks itself? Would it be better? As per design considerations?
2) How should deletion be done? Should Standalone class have a method for song deletion? Or should activity
be implementing the LoaderCallbacks
itself and a DAO like class have method for song deletion?
Try using ContentOberver. This will give you callback whenever your dataset have change. Refer this link