Search code examples
androidjsonofflineoffline-caching

to store json data and made available to user when network is not available android(offline)


**how to store json data and show when network is not available

First when user login and go through home screen of application and when user network is not available still user can browse through the data.


Solution

  • You can achieve this in multiple ways by using storage options:

    http://developer.android.com/guide/topics/data/data-storage.html

    I suggest use the shared preferences to achieve the following

    1. Store the Login details when user log in for first time.
    2. When user opens the app check if login details exist in some loading activity. If exist redirect him to desired screen using startActivity. If login details doesn’t exists or expired then redirect to the login page.
    3. When user logout of the app delete the details stored in prefs.

    Refer this for example How to keep android applications always be logged in state?