Q:

How to replace activity cached data with new data from server in recommended way

My activity display data that is being fetched from the server every time the user see the activity (onResume) in order to see the most latest data. I am caching the data onPause in order to show the user the previous data (so he won't see white page or loading message) before fetching the new data and replacing the cached data with the new data. The problem is that the user can open the activity, see a number and after 3 second the number is changing (because of the new data). Is this the only way I can achieve what I need?
This is the life cycle: onResume -> getting data from cache and displaying it -> going to the server and fetching new data -> replacing the data in the activity -> onPause -> caching the new data.

EDIT: Let me try to clarify my problem. It can take up to 10 - 15 seconds for the data to be retrieved from the server. In this time I don't want the user to see loading screen (or should I) so I am presenting him the latest cached data. But now, the user can click on a rate me button on the basis that this item have 4 starts although after 15 seconds is changing to 3 starts.

A:

The best UI practice is to show to the user that data is loading instead of white screen. Showing old data is even worse, because if connection goes wrong the user won't get know that he is using outdated data.
Put ProgressBar or some funny animations (as in Snapchat) onto your activity layout and hide it after loading finishes.
Other solution is to create a singleton object with a thread in it which receives data from the server periodically, for example, every minute, and stores them within this singleton. Every time your activity resumes, just call singleton instance to get fresh data from it.

