0

I am trying to write a file in android using phonegap cordova 1.5.0. Below is the code snippet. This snippet is working fine in simulator but when I run this on my android mobile it goes till gotFs() then "fail error code" alert of fail() pops up with message

"fail error code 1"

that means it is failing at line

fileSystem.root.getFile("projectFileName", {create: create: true, exclusive: false}, gotFileEntry, fail);

.

code snippet

         function onDeviceReady() {
                window.requestFileSystem(LocalFileSystem.PERSISTENT, 0, gotFS, fail);
           }

               function gotFS(fS) {
            fileSystem = fS;
            fileSystem.root.getFile("projectFileName", {create: create: true, exclusive: false}, gotFileEntry, fail); 
          }

          function gotFileEntry(fE) {
            fileEntry = fE;
            fileEntry.createWriter(gotFileWriter, fail);
          }


          function gotFileWriter(writer) {
           .......... file writing code.
          }

         function fail(error) {
            alert('fail error code = '+error.code);
            alert('error '+error);
            console.log(error.code);
         }

The simulator avd is 2.3.3 and my device has android 2.3.6.

4

1 回答 1

2
 fileSystem.root.getFile("projectFileName", {create: create: true, exclusive: false}, gotFileEntry, fail);

to

 fileSystem.root.getFile("projectFileName", {create: true, exclusive: false}, gotFileEntry, fail);
于 2012-06-26T12:16:04.837 回答