I'm trying to write to the external storage (virtual SD) of an android tablet using Cordova. In fact, i'm trying to access a 'www' directory created by 'bitwebserver' (a LAMP for android).
I have the following piece of code
But i can't get to create the file, I either get a 5 or 9 error code.
What am I missing here ?
Thanks !
<script>
    // Wait for Cordova to load
    document.addEventListener("deviceready", onDeviceReady, false);
    // We're ready
    function onDeviceReady() {
        window.requestFileSystem(LocalFileSystem.PERSISTENT, 0, gotFileSystem, fail);
    }
    function gotFileSystem(fileSystem) {
        fileSystem.root.getFile(cordova.file.externalRootDirectory + "/www/test.txt", {
            create: true,
            exclusive: false
        }, gotFileEntry, fail);
    }
    function gotFileEntry(fileEntry) {
        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) {
                console.log("contents of file now 'some sample'");
                writer.seek(4);
                writer.write(" different text");
                writer.onwriteend = function (evt) {
                    console.log("contents of file now 'some different text'");
                }
            };
        };
        writer.write("some sample text");
    }
    function fail(error) {
        console.log(error.code);
        console.log(error);
    }
</script>
 
    