Saving a file in the device storage
Thanks to the ability to traverse, read, and write to the device filesystem, an application can write a file to either a specific, predefined location or 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 in a textbox to download and save that file in their mobile device:
- Firstly, create a new PhoneGap project named
storage
by running the following line:phonegap create storage com.myapp.storage storage
- Add the devices platform. You can choose to use Android, iOS, or both:
cordova platform add ios cordova platform add android
- Add the
file
andfile-transfer
plugins by running this line:phonegap plugin add org.apache.cordova.file phonegap plugin add org.apache.cordova.file-transfer
- We're going to use the
XUI
JavaScript library to easily access the DOM elements, so we'll include the reference to the file within thehead
tag. - Let's open
www/index.html
and clean up the unnecessary...