簡體   English   中英

無法訪問根目錄phonegap

[英]Can't get access to the root directory phonegap

目前,我正在一個項目中,必須訪問Root中的Music目錄。 我正在嘗試使用Phonegap / Cordova插件獲取目錄: https : //github.com/apache/cordova-plugin-file

我嘗試了很多事情,並在Google上進行了研究,但找不到任何好的方法。這是我的代碼:

/* THIS IS PLACED IN THE onDeviceReady FUNCTION! */        
window.requestFileSystem(window.TEMPORARY, 1024*1024, onFileSystemSuccess, function(e) { alert("Something went wrong.."); });
alert( "5" );
/*************************************************/

    function onFileSystemSuccess(fileSystem) {
        alert("6"); // just for testing
        fileSystem.root.getDirectory("Music", {}, getDirSuccess, function(e) { alert("Doesn't work"); } );
    }

    function getDirSuccess(dirEntry) {
        alert("7");
        var directoryReader = dirEntry.createReader();
        directoryReader.readEntries(readerSuccess,fail);
    }

嗯...如果您要讀取文件系統,則可能要嘗試使用window.resolveLocalFilesystemURL()而不是window.requestFilesystem()

我有一個示例例程,可以在這里遍歷一堆目錄: 如何在PhoneGap將看到的android目錄中獲取文檔 這可能有助於縮小搜索范圍。

嘗試以下路徑:

/android_asset/www/song.mp3

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM