I created a web application that I need to convert to a mobile application, now all I have is html5/js/css files which means I don't have any www foder no platforms folder, not a cordova project ... I started first to build the app using cordova command lines, but I couldn't, I found many problems on that, I used then https://build.phonegap.com/ , and it works fine for me. In order to read the file, I have tried this code :
window.resolveLocalFileSystemURI("file:///android_asset/www/data/User.xml", function () {
alert("Success");
}, function () {
alert(" error ");
});
but, it didn't work. I added a try catch
, the exception was :
window.resolveLocalFileSystemURI is not a function
Do i need to add something to my code to make it work ?
You need to install a plugin for this to work.
Basically, run "cordova plugin add org.apache.cordova.file" at your application's root directory.
For detailed instructions see here, under "Accessing the Feature": http://docs.phonegap.com/en/edge/cordova_file_file.md.html#LocalFileSystem
UPDATE 2019
The correct way to add this plugin is now with this command in your project root:
cordova plugin add cordova-plugin-file
This is a core cordova plugin. Documentation found here on npm
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With