Preloader
Cordova
  • Estimated reading time: 1 Minute

How to create file with Cordova

Create a file in cordova is pretty easy, use the following code to create file in a specific folder. This code works in all cordova platforms ()

var path = "file:///storage/emulated/0";
var filename = "myfile.txt";

window.resolveLocalFileSystemURL(path, function(dir) {
	dir.getFile(filename, {create:true}, function(fileEntry) {
            // The file has been succesfully created. Use fileEntry to read the content or delete the file
	});
});

Remember that you need the file plugin from cordova, read and learn how to use it here. You can download the file plugin into your project 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.