I’m developing a corodva (phonegap) application and I’m saving some downloaded files to the data directory. Currently if I’m accessing the filesystem entry to the target file in the following way:
function gotFS(fileSystem) {
fileSystem.root.getFile("<filename>", {create: true}, gotFileEntry, fail);
}
window.requestFileSystem(LocalFileSystem.PERSISTENT, 0, gotFS, fail);
I tried with LocalFileSystem.APPLICATION but it gives a javascript error.
In iOS the file gets saved into /Documents/<filename> , and in android into /mnt/sdcard/<filename>.
I want to store those files in /data/data/<app>/<filename> in Android and the equivalent in iOS (which I guess is /Application Support/<filename>).
Now the question is:
Is there a way to access these in a platform independent way so I don’t need to add ifs to check in which platform I am?
I wrote up a small blog post to show how to move platform dependent paths out to a json file you load at startup. That way you don’t have to do the clunky tests for what platform you are on.
http://simonmacdonald.blogspot.com/2012/01/on-eleventh-day-of-phonegapping.html