Is it possible to list the files inside the www PhoneGap folder? And recursively?
I need it because I would like to preload all the images inside it.
The official documentation for working with files in phonegap can be rather hard to get started with.
Here's a working example of listing the files in a folder other than the root (in this case one called Downloads).
window.requestFileSystem(LocalFileSystem.PERSISTENT, 0, function(fileSystem) {
fileSystem.root.getDirectory("Downloads", {
create: true
}, function(directory) {
var directoryReader = directory.createReader();
directoryReader.readEntries(function(entries) {
var i;
for (i=0; i<entries.length; i++) {
log(entries[i].name);
}
}, function (error) {
alert(error.code);
});
} );
}, function(error) {
alert("can't even get the file system: " + error.code);
});
Note this will give you a directory in the writable area (Documents on iOS, sdcard on Android, so may not help that much).
here's a PhoneGap app that does just that, even if written for BlackBerry, the jscript/html code is the same and should work in your iOS app as well.
Hope this helps
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