I'm using Phonegap 3.3.0, earlier i used 2.5.0 where entry.fullPath will give the Device full path. These paths would typically look like
/var/mobile/Applications/<application UUID>/Documents/path/to/file (iOS)
/storage/emulated/0/path/to/file (Android)
since that method is deprecated am using entry.toURL() method to get the path.This method will now return filesystem URLs of the form
cdvfile://localhost/persistent/path/to/file
In My application, am passing the URL to Native function and from native am opening a file. But If I pass the path to Native, iOS could not able to detect the file. The same If i hardcode the Absolute path, application detects the file.
How to use the fileSystem URL to access the file in native or any other method to get the device absolute path ?
Thanks in advance.
The toURL()
method or the nativeURL
attribute should return the result wanted:
window.requestFileSystem(LocalFileSystem.PERSISTENT, 0, function(fileSystem){
console.log("fileSystem.root.toURL()="+fileSystem.root.toURL());
console.log("fileSystem.root.toInternalURL()="+fileSystem.root.toInternalURL());
console.log("fileSystem.root.nativeURL="+fileSystem.root.nativeURL);
}, function(){
alert("fails!");
});
Using cordova 3.5, the output in iPad simulator is:
fileSystem.root.toURL()=file:///Users/myuser/Library/Application%20Support/iPhone%20Simulator/7.1/Applications/1717CB5F-4032-45C7-8CA2-342502447F36/Documents/
fileSystem.root.toInternalURL()=cdvfile://localhost/persistent/
fileSystem.root.nativeURL=file:///Users/myuser/Library/Application%20Support/iPhone%20Simulator/7.1/Applications/1717CB5F-4032-45C7-8CA2-342502447F36/Documents/
...and in Android simulator (Genymotion) is:
fileSystem.root.toURL()=file:///storage/emulated/0/
fileSystem.root.toInternalURL()=cdvfile://localhost/persistent/
fileSystem.root.nativeURL=file:///storage/emulated/0/
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