Search code examples
androidoffline-caching

How does facebook or instagram app retain images or data after entering the app with no internet connection?


In Facebook app, for example, I login with my internet connection. Then I close the app, turn off the internet and close all my system tabs. Then even though my internet connection is off, I see the images and data that had been previously loaded still retained.

How does Facebook app do that? What should I do if wanted to implement such a feature in my Android app?


Solution

  • i use 'Picasso' Library for caching, loading... images from internet :

    http://square.github.io/picasso/

    Automatic memory and disk caching

    Picasso.with(context)
       .load(url)
       .resize(50, 50)
       .centerCrop()
       .into(imageView)
    

    for data, you can store data using shared preferences for small stuff or a local database like sqlite