Book Image

PhoneGap 4 Mobile Application Development Cookbook

Book Image

PhoneGap 4 Mobile Application Development Cookbook

Overview of this book

Table of Contents (19 chapters)
PhoneGap 4 Mobile Application Development Cookbook
Credits
About the Authors
About the Reviewer
www.PacktPub.com
Preface
Index

Caching content using the local storage API


As mobile users access applications and pull remote data on the move, we need to be conscious and aware that our application may be using up the limited data services. We can implement services and techniques to help reduce unnecessary remote calls to data.

How to do it...

In this recipe, we will build an application that allows the user to search Twitter using its open API. We'll store the results for the search in localStorage so that they are available when we reopen the application:

  1. Firstly, create a new PhoneGap project named localstorage by running this line:

    phonegap create localstorage com.myapp.localstorage localstorage
    
  2. Add the devices platform. You can choose to use Android, iOS, or both:

    cordova platform add ios
    cordova platform add android
    
  3. We will be using the jQuery Mobile framework for our layout, so we include the relevant CSS and JavaScript file references within the head tag.

  4. Open www/index.html and clean up the unnecessary elements...