0

Every time the application is opened, it should check for updates through the API link and update the database, if an internet connection is not found, then display the data stored in the database.

How to do this ? Should I use Loaders here ?

  • 1
    Please add more information: 1. How do you access the API? 2. What format is the data? 3. Also please show your current code, otherwise we can't give you solutions that will work for your specific project – Mor Paz Mar 19 '16 at 14:04
  • @MorPaz, Accessing API in doInBackground() using AsyncTack, parsing JSON format data & storing in String title & imageUrl. – Jay Prakash Thakur Mar 19 '16 at 14:10

1 Answers1

1

Based on the information you provided, I suggest you refer to this answer. It shows you how to check if the device is connected to the internet.

You can check if the device is connected, if it is - Perform async task, update the DB and then display the new information.

If the device isn't connected, skip the async task and display the information that is already stored on the device. You should also display a message to the user (i.e. via snackbar or toast) that the device is not connected and you are displaying old information.

Hope this help, good luck!

Edit: Fixed typos

Community
  • 1
  • 1
Mor Paz
  • 2,088
  • 2
  • 20
  • 38