My app copies files on the device using the FileAPI
. This works well in Phonegap 3.4.0 and 3.5.0.
Then it opens an html file by doing window.location = "cdvfile://localhost/persistent/TEST/index.html";
(note that the path is not hard coded but uses something like myDirEntry.toURL()
, and that both 3.4 and 3.5 give the same path).
This works well in 3.4.0 (tested on several versions of Android and iOS), but it does not work in 3.5.0 (tested only on Android 4.1.2 and 4.4.2).
When trying to change the location, nothing happens. The app stays in the current page, no exception seems to be thrown.
In both cases I use the org.apache.cordova.file
plugin version 1.0.1 (the one available on Phonegap Build).
Has something changed in Phonegap 3.5.0?
For some reason you simply need to use toNativeURL
instead of toURL
in Phonegap 3.5 (tested on Android):
toURL
gives me cdvfile://localhost/persistent/Path/To/Folder
toNativeURL
gives me file:///storage/sdcard0/Path/To/Folder
Using toNativeURL
has the advantage to use the file
protocol instead of cdvfile
, so that there's no same-origin policy issue (cf my other question AJAX blocked when using cdvfile - Phonegap).
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