List of files inside the www folder in PhoneGap

Can I list files in www PhoneGap folder? And recursively?

I need this because I would like to preload all the images inside it.

+6
source share
2 answers

here is the PhoneGap application that does just that, even if it is written for BlackBerry, the jscript / html code is the same and should work on your iOS as well.

Hope this helps

+2
source

The official documentation for working with files in a phone saver can be quite complicated.

Here is a working example of listing files in a folder other than the root (in this case, one is 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); }); 

Please note that this will give you a directory in the recording area (documents on iOS, sdcard on Android, so that may not help much).

+3
source

Source: https://habr.com/ru/post/902571/


All Articles