开发者

Local File path not found Phonegap

"readme.txt" not found. Phonegap example are not working on iphone and android


              document.addEventListener("deviceready", onDeviceReady, false);

          function onDeviceReady() {
              window.requestFileSystem(LocalFileSystem.PERSISTENT, 0, gotFS, fail);
          }
          function gotF开发者_如何学编程S(fileSystem) {
              fileSystem.root.getFile("readme.txt", null, gotFileEntry, fail);
          }

          function gotFileEntry(fileEntry) {
              console.log(evt.target.error.code);

          }


          function fail(evt) {

              console.log(evt.target.error.code);
          }


You can only get file in the Document folder of the application.

If the file is not found you can create it by replacing 'null' with {create: true} in the getFile() function like so

    <script type="text/javascript" charset="utf-8">
        document.addEventListener("deviceready", onDeviceReady, false);

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

        function gotFS(fileSystem) {
            fileSystem.root.getFile("readme.txt", {create: true}, gotFileEntry, fail);
        }

        function gotFileEntry(fileEntry) {
            console.log("gotFileEntry");
        }

        function fail(evt) {
            console.log("Error : "+evt.code);
        }
    </script>
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜