U
U
udenfox2015-04-14 13:10:30
Android
udenfox, 2015-04-14 13:10:30

Android: local caching of data from a REST service. How to implement?

For educational purposes, I am writing a simple messenger for android.
Data such as a list of chats, a list of contacts, chat history and information about the user are received by the application from the server via REST.
After researching the issue of REST libraries for android, I chose Retrofit as the most convenient and adequate in terms of speed.
But at this stage, it was also necessary to cache the whole thing, that is, save the received data in a local database, so that if the user starts the application without access to the network, he will display the data that was received last time.
For example, what we have now:
The user enters the application while connected to the Internet, the application uploads a list of chats from the server and throws them on the activity.
If you close the application and go into it already WITHOUT a connection, there will be no data on the screen until it becomes possible to upload them from the network.
As we would like:
If the Internet is available, the application unloads the data and throws them on the view, but, among other things, writes it to the database. When the data is updated, the database is also updated.
If there is no Internet, data from the database is loaded.
Interested in what to use for implementation and how to organize the work of all this.
I looked in the direction of RoboSpice, but there seems to be a little not what you need.
Tell me, huh? And then I got confused with all this.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
anyd3v, 2015-04-14
@udenfox

first to Google for the following words with the prefix android: Sqlite, Cursor, CursorAdapter, ContentResolver

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question