I have an instagram like app in which I receive data from a server(imageUrl, username, about) and I store it in a cursorLoader and after that I take the data from the cursorLoader and put it in a RecyclerAdapter. The images are being loaded using the Volley library.
I recently found out about the realm library. Should I use this instead of the cursorLoader ? I'm not even sure why I needed the cursor loader, but I implemented it and it's working. I think I only need to store the user once connected so it doesn't have to connect every time the app is called if he did not disconnect. Which would be the best approach to make this app work smoothly.
Which is the best way to keep some data displaying like the instagram/facebook feed once it was downloaded (even after the user killed the app and turned it on again). Could you give me any tips ?
If you want to store data after they have been downloaded and have it persisted between app restarts, then a database is a good choice. Whether you want to use normal Cursors, some ORM or Realm is really up to what you value and what trade-offs you are willing to accept.
That said, the primary reason for a CursorLoader is to
Load a lot of data asynchronously.
Hook into change notifications from a ContentProvider
If you don't use a ContentProvider, a CursorLoader looses a lot of its power.
The same functionality a CursorLoader provides (automatic refresh on changes/handle lots of data) can be expressed with far less code using Realm:
RealmResults<ServerData> results = realm.where(ServerData.class).findAllAsync();
RealmBaseAdapter adapter = new RealmBaseAdapter(context, results, true);
listView.setAdapter(adapter);