Phonegap Filewriter Append Issue
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
Solution 1:
I found a workaround to that :
functiongotFileWriter(writer) {
writer.onwrite = function(evt) {
console.log("write success");
};
writer.write("some sample text");
// contents of file now 'some sample text'
writer.abort();
writer.truncate(11);
// contents of file now 'some sample'
writer.abort();
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");
}
Solution 2:
The file handling is asynchron. You can't simply do the file operations step by step. You have to wait for the onwrite events, before making the next step. writer.abort() may fix the error. But you can't be sure what is stored.
Post a Comment for "Phonegap Filewriter Append Issue"