1

What is the path in hybrid apps for android,windows and ipad for files stored inside project solution as www->data->filename.doc? I want to access these files and open them.

1 Answers1

0

I think cordova.file.applicationDirectory is what you are after.

For example on iOS and Android I would do:

window.resolveLocalFileSystemURL(cordova.file.applicationDirectory + 'www/data/filename.doc', win, fail); 

And on Windows (8 anyway) which confused me for a while, I would do:

Windows.Storage.StorageFile.getFileFromApplicationUriAsync(new Windows.Foundation.Uri(cordova.file.applicationDirectory + 'www/data/filename.doc')).done(gotControls, fail);

Make sure you have the two file plugins installed also:

cordova plugin add cordova-plugin-file
cordova plugin add cordova-plugin-file-transfer

Hope that helps.

EDIT: I have just read this again and realised you just wanted to open the files, the above is still relevant for the file paths but I would look into using this open plugin: https://github.com/disusered/cordova-open to actually open the files, I have not tried it with a .doc file before but it will work with .pdf files.

This can be called as:

var open = cordova.plugins.disusered.open;
open(encodeURI(url), success, error);   
Pyper
  • 21
  • 8