Trying to use phonegap 0.9.6 file storage. The code works fine while I am writing a file but does not work when I try to append to the file (using seek, truncate etc.).
There was a bug in version 0.9.5 that seems to be fixed.
The code just terminates when I call writer.seek. The alert after truncate (or if I delete the truncate the seek) is not being called at all.
Should I set an append flag somewhere? The doc says that but does not give an example as to where I should be setting the append flag. The code is as follows
function gotFS(fileSystem) {
fileSystem.root.getFile( "test.txt", {"create":true,
"exclusive":false}, gotFileEntry, fail);
}
function gotFileEntry(fileEntry) {
fileEntry.createWriter(gotFileWriter, fail);
}
function gotFileWriter(writer) {
writer.onwrite = function(evt) {
console.log("write success");
};
writer.write("some sample text");
// contents of file now 'some sample text'
writer.truncate(11);
alert('truncated');
// contents of file now 'some sample'
writer.seek(writer.length); //writer.seek(4) does not work either
// contents of file still 'some sample' but file pointer is after the 'e' in 'some'
writer.write(" different text");
// contents of file now 'some different text'
alert('success with diff text');
}
Any help would be appreciated.
I found a workaround to that :