O'Reilly logo

PhoneGap Mobile Application Development Cookbook by Matt Gifford

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

Opening a local file from device storage

When developing your mobile application, you may need or want to read particular files from the storage system or from another location on the device.

How to do it...

In this recipe we will build an application that will create a text file on the phone's storage file system, write content into the file, and then open the file to display the content, as listed in the following steps.

  1. Create the initial HTML layout for our application. We're going to use the XUI JavaScript library to easily access DOM elements, so we'll include the reference to the file within the head tag along with the cordova-2.0.0.js file.
  2. Below the Cordova JavaScript reference let's also create a new JavaScript tag block to hold our custom ...

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