I’m developping an application for mapping…
I created KML and JSON string and I need to store them in files in phones memory, to do so, I used the following code :
> var fileObject;
> document.addEventListener("deviceready", onDeviceReady, true);
>
> function onDeviceReady()
> {
> window.requestFileSystem(LocalFileSystem.PERSISTENT, 0,onFileSystemSuccess, fail);
> }
> function onFileSystemSuccess(fileSystem) {
> fileSystem.root.getFile("readme.txt",{create: true, exclusive: false},gotFileEntry, fail);
> }
> function gotFileEntry(fileEntry) {
> fileObject = fileEntry;
> $('#saveFile_btn').on('click', function() {
> saveFileContent();
> });
> }
> function saveFileContent() {
> fileObject.createWriter(gotFileWriter, fail);
> }
> function gotFileWriter(writer) {
> var myText = document.getElementById('my_text').value;
> writer.write(myText);
> writer.onwriteend = function(evt) {
> $('#message').html('<p>File contents have been written.<br /><strong>File path:</strong> ' + fileObject.fullPath + '</p>');
> var reader = new FileReader();
> reader.readAsText(fileObject);
> reader.onload = function(evt) {
> $('#contents').html('<strong>File contents:</strong> <br />'+ evt.target.result);
> };
> };
> }
> function fail(error){
> alert(error.code);
> }
the result was not an error, but I can’t find the file in the memory.