Get ready to render the first available image in the device's storage into the PhoneGap default app template. Refer to the following steps:
Open the command-line tool and create a new PhoneGap project named
ReadingFile
.Add the File API plugin using the following command line:
$ cordova plugin add cordova-plugin-file
Go to the
www
folder, open theindex.html
file, and add animg
tag with theid
value asfirstImage
inside the maindiv
of the app following thedeviceready
one:<img id='firstImage' />
Go to the
www/js
folder, open theindex.js
file, and define a new function namedrequestFileSystem
:Function requestFileSystem() { // The request of access to the file system will go here }
Define the error handler in order to get the code of every possible error:
Function onError(error){ alert(error.code); }
In the body of the
requestFileSystem
function, access the device filesystem using therequestFileSystem
function of theLocalFileSystem...