开发者

Phonegap - Filewriter only writes the first line

开发者 https://www.devze.com 2023-04-03 05:47 出处:网络
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.

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

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号