2
I am trying to remove all files from a folder using Cordova and Android, the problem is that every code I think, only shows how to remove FILES and not FILES FROM A FOLDER.
The problem is I don’t know the name of the files.
Here is an example of code to remove files (I need to remove FILES from which I don’t know the name of a folder)
var path = cordova.file.applicationStorageDirectory;
var filename = "arquivoABC.txt";
window.resolveLocalFileSystemURL(path, function(dir) {
dir.getFile(filename, {create:false}, function(fileEntry) {
fileEntry.remove(function(){
// The file has been removed succesfully
},function(error){
// Error deleting the file
},function(){
// The file doesn't exist
});
});
});
There’s no such thing as $cordovaFile in my app.
– PauloHDSousa
@Paulohdsousa In your case instead of being
dir.getFile
would bedir.removeRecursively
.– viana
I solved it a little differently, removeRecursively didn’t work, but I did something similar, follow.
– PauloHDSousa