Answer the question
In order to leave comments, you need to log in
Need to figure out how to create a cordova/phonegap file?
I can’t understand why there is no file in the file system after its creation, I reviewed a bunch of examples, and re-read the dock 10 times, but nothing.
When the function is executed, everything goes smoothly,
every step was debugged, but there is no file in the file system.
What am I missing, what am I doing wrong, please?
I am attaching the code:
window.requestFileSystem(LocalFileSystem.PERSISTENT, 0, function(fileSystem) {
//console.log(fileSystem.name);
//console.log(fileSystem.root.name);
//console.log(fileSystem.root.fullPath);
fileSystem.root.getFile("test.txt", {create: true}, function(entry) {
var fileEntry = entry;
console.log(entry);
entry.createWriter(function(writer) {
writer.onwrite = function(evt) {
console.log("some sample text");
};
console.log("writing to file");
writer.write("some sample text");
}, function(error) {
console.log(error);
});
}, function(error){
console.log(error);
});
},
function(event){
console.log( evt.target.error.code );
});
Answer the question
In order to leave comments, you need to log in
Those. you have already installed the plugin.
Try opening the directory before opening the file:
window.resolveLocalFileSystemURL(
cordova.file.dataDirectory,
function(dirResolved) { /* getFile и т.д. */ },
function(err) { /* обработка ошибок */}
);
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question