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
Become a more social person