Book Image

Xamarin Mobile Application Development for Android, Second Edition

Book Image

Xamarin Mobile Application Development for Android, Second Edition

Overview of this book

Table of Contents (18 chapters)
Xamarin Mobile Application Development for Android Second Edition
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

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:

  1. Call the CreateTable() method on the POIListActivity class to initiate the database:

    DBManager.Instance.CreateTable();
  2. Open the POIListFragment class and go to the DownloadPoisListAsync() method. We have used this method to download the POI list from the server. The following updates are required here:

    1. Clear the database cache when the POI downloads from the server are successful.

    2. Save the newly fetched POI data to the database.

    3. 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...