vendredi 11 septembre 2015

Refresh RecyclerView with latest data dynamically

I have a SQLite database in my app for which I made a ContentProvider class.

I also have a RecyclerView into which I load an ArrayList of objects into its adapter to populate the RecyclerView.

Currently, when the activity starts I get a Cursor via my ContentProvider, loop through the Cursor to create an ArrayList of objects that I then set as part of my RecyclerView.Adapter.

All that works, but what I really want is for my RecyclerView to dynamically update as new data is loaded into the SQLite database.

I have seen posts listing this library CursorRecyclerAdapter but I really do not understand how this all works.

Does anyone have an example of the above library in action or some other method to dynamically populate my RecyclerView with the latest data while the user is looking at the activity?

Thanks.

Aucun commentaire:

Enregistrer un commentaire