Cari95
Cari95

Reputation: 313

How could i manually update the recyclerview of my app?

I am new to Android development. I intended on users to submit their information via Google Docs until I created a website for my app. I currently have a recyclerview to display posts. These posts consist of imageviews and textviews. My question is what is the most efficient way I could update my recylerview to display their submitted information if approved. If not plausible what would you suggest to manage the content in my program? Also keep in my mind I plan on developing the same application in Ios in the future and would like for each app to display the same information.

Upvotes: 1

Views: 222

Answers (1)

tobs
tobs

Reputation: 719

You could represent the data fetched from your web service in an SQLite Database (a good tutorial on how to create/access sqlite databases in android can be found here: http://www.androidhive.info/2011/11/android-sqlite-database-tutorial/).

Then you could use a CursorLoader and a CursorAdapter for the RecyclerView and swap the cursor when the loader finishes.

If you are modifying your dataset simply call onContentChanged() and your loader will requery and publish the results automatically.

Here you'll find a decent CursorAdapter implementation for RecyclerView: https://gist.github.com/skyfishjy/443b7448f59be978bc59

And here is a good documentation on how to use the CursorLoader with the LoaderCallbacks: https://developer.android.com/training/load-data-background/setup-loader.html

Upvotes: 1

Related Questions