Phonegap - Filewriter only writes the first line
I am using the sample code from the docs and only the first write instance is being executed. The function just ends after that with no error.
The resulting file contains the text: "s开发者_StackOverflow社区ome sample text"
Any ideas?
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);
// contents of file now 'some sample'
writer.seek(4);
// 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'
}
You need to add write.abort()
between each lines
Take a look at my answer to this thread :
phonegap filewriter append issue
精彩评论