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 ?
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 ?
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