write/read a file?
I tried this, it didn't work. Another question how can I read a file with path.
code
function saveTheFile(filename, content) {
window.requestFileSystem(LocalFileSystem.PERSISTENT, 0, function(fs) {
fs.root.getFile(filename, { create: true }, function (fileEntry) {
Code: Select all
fileEntry.createWriter(function (fileWriter) {
fileWriter.onwriteend = function (e) {
};
fileWriter.onerror = function (e) {
alert('Error occured: ' + e.toString() + "\n File couldn't saved");
};
var contentBlob = new Blob([content], { type: 'text/plain' });
fileWriter.write(contentBlob);
}, handleError);
}, handleError);
}
);
}
saveTheFile(bg.txt,"aaaaa");
/code