Cordova List All Files from Application Directory (Www)

Cordova list all files from application directory (WWW)

You can use this function to get all available files in www/audio/ folder

function listDir(path){
window.resolveLocalFileSystemURL(path,
function (fileSystem) {
var reader = fileSystem.createReader();
reader.readEntries(
function (entries) {
console.log(entries);
},
function (err) {
console.log(err);
}
);
}, function (err) {
console.log(err);
}
);
}
//example: list of www/audio/ folder in cordova/ionic app.
listDir(cordova.file.applicationDirectory + "www/audio/");

how to access all files from any one folder in mobile file manager in ionic 1

cordova-file is what you are looking for.

You can use this function to get all available files in a folder:

function listDir(path){
window.resolveLocalFileSystemURL(path,
function (fileSystem) {
var reader = fileSystem.createReader();
reader.readEntries(
function (entries) {
console.log(entries);
},
function (err) {
console.log(err);
}
);
}, function (err) {
console.log(err);
}
);
}
//example: list of www/ folder in cordova/ionic app.
listDir(cordova.file.applicationDirectory + "directory/path");

see this also: Cordova list all files from application directory (WWW)

Get list of files in a directory in cordova

Just put the console.log in the if-statement:

function success(entries) {
if (entries.length == 0)
console.log("No Records");
else
{
for (var i = 0; i < entries.length; i++) {
entries[i].file(function (file) {
console.log("file.name " + file.name);
})
}
console.log('file list created');
}
}

Accessing Android Environment directories in Cordova

As I found no way to get those folders path with built in cordova functions, I made a quick little plugin that allows to get all the paths exposed through the Environment object.

https://github.com/nicolasgrolleau/androidfoldersplugin/

And that shows how easy building a cordova plugin can be.

Get internal application directory in Cordova + android

from cordova file 3.0.0, the default LocalFileSystem.PERSISTENT is the /data/data/app.package

on previous versions you can get it using

window.resolveLocalFileSystemURL(cordova.file.applicationStorageDirectory, success, fail);


Related Topics



Leave a reply



Submit