I am using cordova and I am trying to create a folder in the root of my SD card on the device. I use the following code to create a folder and add the login.txt file to it:
window.requestFileSystem(LocalFileSystem.PERSISTENT, 0, gotFS, fail); function gotFS(fileSystem) { fileSystem.root.getDirectory("citylook", {create: true}, gotDir); } function gotDir(dirEntry) { dirEntry.getFile("login.txt", {create: true, exclusive: true}, gotFile); } function gotFile(fileEntry) { // Do something with fileEntry here fileEntry.createWriter(gotFileWriter, fail); } function gotFileWriter(writer) { writer.onwriteend = function(evt) { console.log("contents of file now 'some sample text'"); writer.truncate(11); writer.onwriteend = function(evt) { writer.seek(0); writer.write(testo); writer.onwriteend = function(evt){ console.log("contents of file now '"+testo+"'"); } }; }; writer.write("some sample text"); } function fail(error) { console.log(error.code); }
Now I need to create a folder inside the "citylook" folder, I will try:
function onDeviceReady() { window.requestFileSystem(LocalFileSystem.PERSISTENT, 0, onSuccess, null); } function onSuccess() { fileSystem.root.getDirectory("citylook", {create: true, exclusive: false}, onGetDirectoryWin, onGetDirectoryFail); fileSystem.root.getDirectory("citylook/nuovo", {create: true, exclusive: false}, onGetDirectoryWin2, onGetDirectoryFail2); } ....
but I canβt create a subfolder .... what's wrong with my code?
Thankyou
SOLVE:
fileSystem.root.getDirectory("citylook", {create: true}, gotDir); fileSystem.root.getDirectory("citylook/subfolder", {create: true}, gotDir);