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.
Asked
Active
Viewed 1,488 times
1

mainprashant89
- 77
- 1
- 9
-
Use this `file:///android_asset/www/data/filename.doc` . – Jay Rathod Apr 06 '16 at 07:37
-
Thanks Jay. Any idea on windows and iOS? – mainprashant89 Apr 06 '16 at 09:24
-
How do you want to access them? – jcesarmobile Apr 07 '16 at 10:59
-
I want to open the docs. – mainprashant89 Apr 08 '16 at 17:49
1 Answers
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