Search code examples
androidcordovacordova-plugin-file

Cordova: where and how install a plugin?


I created a fresh new app.

Then I went to the www directory and executed npm install cordova-plugin-file.

And now? What must I do to work with this plugin in the app?

If I do a cordova plugin list it shows me only the whitelist plugin, created by default from cordova itself.

I then tried cordova plugin add cordova-plugin-file and now cordova plugin list shows me both whitelist and file plugin.

And now? When I tried the following code I got that, on Android emulator, cordova.file is undefined

window.resolveLocalFileSystemURL(cordova.file.dataDirectory, function(dir) {
    console.log("got main dir", dir);
});

Solution

  • The problem here was simply that the whole app must be wrapped into the deviceReady event handler, but ... not this code ... damn... now it works