O'Reilly logo

PhoneGap 4 Mobile Application Development Cookbook by Zainul Setyo Pamungkas

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required