Ripple Emulator和cordova代码访问文件系统不运行

时间:2014-10-16 11:13:38

标签: android jquery-mobile cordova netbeans cordova-plugins

我在netbeans中使用Cordova 3.6.3创建了一个应用程序,并尝试使用Ripple 0.9.15进行模拟。 每当我运行代码时,我都会得到:

Uncaught TypeError: Cannot read property 'fire' of undefined ripple.js:40
deviceready has not fired after 5 seconds. cordova.js:1168
Channel not fired: onPluginsReady cordova.js:1161
Channel not fired: onCordovaReady

代码应该访问文件系统,创建一些文件并显示它们 列表视图。这是:

    <!DOCTYPE html>
    <!--
    To change this license header, choose License Headers in Project Properties.
    To change this template file, choose Tools | Templates
    and open the template in the editor.
    -->
    <html>
    <head>
    <title>Directory Reader</title>
    <meta name="viewport" content="user-scalable=no,
          initial-scale=1, maximum-scale=1,
          minimum-scale=1, width=device-width" />
    <link rel="stylesheet" href="css/jquery.mobile-1.4.3.min.css" />


    <script type="text/javascript" src="js/libs/jquery/jquery-1.10.0.min.js"></script>
    <script src="js/libs/jquery-mobile-1.4.3/jquery.mobile-1.4.3.js"></script>

    <script type="text/javascript" src="cordova.js"></script> 
    <script type="text/javascript">
        document.addEventListener("deviceready", onDeviceReady, false);
        function onDeviceReady() {navigator.alert('file access');
            window.requestFileSystem(
                    LocalFileSystem.PERSISTENT,
                    0, onFileSystemSuccess, fail
                    );     navigator.alert('file access');
        }
        function onFileSystemSuccess(fileSystem) {
            // Create some test files
            fileSystem.root.getDirectory("myDirectory",
                    {create: true, exclusive: false},
            null, fail);
            fileSystem.root.getFile("readthis.txt",
                    {create: true, exclusive: false},
            null, fail);
            var directoryReader = fileSystem.root.createReader();
            // Get a list of all the entries in the directory
            directoryReader.readEntries(success, fail);

        }
        function success(entries) {
            var i;
            var objectType;
            for (i = 0; i < entries.length; i++) {
                if (entries[i].isDirectory === true) {
                    objectType = 'Directory';
                } else {
                    objectType = 'File';
                }
                $('#directoryList').append('<li><h3>' + entries[i].name + '</h3><p>' +         entries[i].toURI() + '</p><p class="ui-li-aside">Type:<strong>' + objectType + '</strong></p></li>');
            }
            $('#directoryList').listview("refresh");
         }
         function fail(error) {
            alert("Failed to list directory contents: " + error.code);
        }

    </script>
     </head>
     <body>
    <div data-role="page">
        <div data-role="header">
            <h2>Directory Reader</h2>
        </div>
        <div data-role="content">
            <ul id="directoryList" data-role="listview"
                data-inset="true">
            </ul>
        </div>
            </div>
        </body>
    </html>

请问我该怎么办?

请问这可能是什么问题?

0 个答案:

没有答案