Get ready to download a file and display in the PhoneGap default app template a progress bar and a link to the file. Refer to the following steps:
Open the command-line tool and create a new PhoneGap project named
DownloadFile
:$ cordova create DownloadFile
Change the directory to
DownloadFile
:$ cd DownloadFile
Add the File and FileTransfer API plugins using the following commands:
$ cordova plugin add cordova-plugin-file-transfer $ cordova plugin add cordova-plugin-file
Go to the
www
folder, open theindex.html
file, and add aprogress
tag with theid
value asprogress
inside the maindiv
element of the app below thedeviceready
tag; assign1
to thevalue
attribute and100
to themax
attribute:<progress id='progress' value='1' max='100'></progress>
Define a new JavaScript function named
onDeviceReady
and add it to thedeviceready
listener:document.addEventListener("deviceready", onDeviceReady, false); function onDeviceReady...