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

Saving a file to device storage

Thanks to the ability to traverse, read, and write to the device filesystem, an application can either write a file to a specific predefined location, or it can be written to a location chosen by the user within the application.

How to do it...

We will allow the user to enter a remote URL for a file into a textbox, and download and save that file to their mobile device. The steps to be performed are as follows:

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

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