Reputation: 41
I want to safe a file in a new directory with PhoneGap and filewriter. I have this code:
fileName = fileSystem.root.fullPath+"/test.html";
var writer = new FileWriter(fileName);
writer.write("ttteeeesssttttt", false);
With this I can create the test.html file and it works. But when I change the path to:
fileName = fileSystem.root.fullPath+"/test/test.html";
it doesn't work....
is there a simple way to solve this problem or should i create the directory first in an other function?
thank you! :)
Upvotes: 0
Views: 2517
Reputation: 293
Check this when onDocumentReady fired:
function CreateFolder(){
window.requestFileSystem(LocalFileSystem.PERSISTENT, 0, creatingFolder, error);
}
This create the folder:
function creatingFolder(fileSystem) {
var entry = fileSystem.root;
entry.getDirectory("test", {create: true, exclusive: false}, win, error);
}
function win(dir) {
console.log("Created dir "+dir.name);
console.log("Created dir "+dir.fullPath);
console.log("Created dir NativePath" + dir.nativeURL);
}
Upvotes: 3