Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

window.resolveLocalFileSystemURI is not a function

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 ?

like image 750
Khalid Avatar asked Apr 30 '15 10:04

Khalid


1 Answers

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

like image 137
Assaf Hershko Avatar answered Oct 13 '22 02:10

Assaf Hershko