Implementing the caching logic to POIApp
The DBManager
class is now tested and ready to use straightaway on POIApp
. The POIApp
will save the POI records when the download is completed, and the list will be retrieved later when the app is unable to fetch the updated list from the server. Perform the following steps to integrate the DBManager
class with POIApp
:
Call the
CreateTable()
method on thePOIListActivity
class to initiate the database:DBManager.Instance.CreateTable();
Open the
POIListFragment
class and go to theDownloadPoisListAsync()
method. We have used this method to download the POI list from the server. The following updates are required here:Clear the database cache when the POI downloads from the server are successful.
Save the newly fetched POI data to the database.
When a device is not connected to the network, return the cached data from the database.
The following code snippet depicts the the updated version of the DownloadPoisListAsync()
method:
public async void DownloadPoisListAsync...