Preloader
Cordova
  • Estimated reading time: 1 Minute

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
Share:
Carlos Delgado

Carlos Delgado

Senior Software Engineer at Corvix. Interested in programming since he was 14 years old, Carlos is a self-taught programmer and founder and author of most of the articles at Our Code World.

Weekly trending
Top 16 Social Media App Development Companies in Denver in 2026
10 Sep, 2026
  • Estimated reading time: 7 Minutes
6 Best Tools for Building an AI Software Factory
10 Sep, 2026
  • Estimated reading time: 9 Minutes
Best Tools for Advancement and Donor Engagement
10 Sep, 2026
  • Estimated reading time: 5 Minutes
Where the Cloud Actually Lives
10 Sep, 2026
  • Estimated reading time: 6 Minutes
Our Sponsors

Our blog is proudly supported by industry-leading sponsors.