1

I want to delete all files from cordova.file.applicationStorageDirectory, and the problem is that I don't have the file names and every code that I found needs a file name.

Here's one example.

var path = "file:///storage/emulated/0";
var filename = "myfile.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
              });
    });
});
PauloHDSousa
  • 65
  • 1
  • 8
  • 2
    You should first list the files in that directory. – greenapps Mar 15 '17 at 13:05
  • I think you can use this example: http://stackoverflow.com/questions/32394003/get-list-of-files-in-a-directory-in-cordova http://stackoverflow.com/questions/28937878/cordova-list-all-files-from-application-directory-www And later delete the files. – Federico Navarrete Mar 15 '17 at 14:26

0 Answers0