B
B
babaevmm2016-05-08 02:47:32
Android
babaevmm, 2016-05-08 02:47:32

What is the correct way to update the list after changing an element?

Hello!
I'm learning android quite recently and got to work with Sqlite. The application is simple (let's say working with notes): 2 activities and 1 fragment for each of them - 1 activity and fragment (A)) List of notes. 2 activities and a fragment (B)) Selected or new note (in edit mode). Structure so to speak according to the textbook. But in real conditions, is it correct?
Fragment to display list of notes is implemented via Fragment, not via ListFragment to use RecyclerView. Is it correct?
And finally, the main question is how, after changing or after inserting a note in fragment B, update the adapter in fragment A, given that they are in different activities now, but can be on the tablet in one?
Now it's done via:
//Method for fragment A, which is launched when the activity is resumed (I don't know if it will be called if there are two fragments A and B in one activity)
@Override
public void onResume() {
super.onResume();
_repository=new DbNoteRepository(new DataBaseHelper(getActivity().getApplicationContext()));
_notes=_repository.selectAll();//get list of notes mAdapter.setDataSet
(_notes);//update source in adapter and call notifyDataSetChange( ) activate for simplicity and clarity

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question