How to delete file with Cordova


Delete a file with cordova is really simple, just use the following code

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
              });
	});
});

Remember that you need the file plugin from cordova, read and learn how to use it here.

You can download the file plugin with 

cordova plugin add cordova-plugin-file
Become a more social person