androidsqlitecachingsharedpreferencesrobospice

SharedPreference or Sqlite Caching and Network Caching Confusion


After going the storage options in android and libraries like robospice and picasso, i am a bit stuck here or say confused.

I have recently implemented and used all of them in my android application, and i also understand the concept of sharedPreference and Sqlite.

But, when it comes to RoboSpice, i am a bit confused as it caches the data but again when an app is killed and again started, it again hits the server for the same data rather than using it from the cache.

Same case with Picasso.

How exactly caching of Robospice and Picasso is different than sharedPreference and Sqlite?

Where their cached data is stored? If not in some file, say in device main memory then they arent used again when app restarts.

Picasso uses http client cache, and caches only static data, like images, that's is also fine.But, in case of network library like robospice, what type of caching they use. Is it stored in some file like sharedPref does? Will it be available after application restarts? Also in case of picasso, will the http cache, will be available after app restarts?

Any help or guideline on this topic will be appreciated.


Solution

  • Shared Preferences and Sqlite happen to be very different from HTTP caching. You use the first two to persist data between app sessions.

    If you wish you can fetch data over the network and save it either to shared preferences or to sqlite and then you would be creating your own caching system on top of those layers. However you would be disregarding the wishes of the web app or the HTTP server when you do that.

    HTTP client libraries on the other hand are bound to check with the web server if the content has expired, and the chances are very likely that if it's dynamically generated content, the web server will tell it that the content has indeed expired. So they have no choice but to fetch the data again.