Firefox OS:访问extsdcard

时间:2014-10-11 08:13:48

标签: javascript firefox gaia

尝试浏览手机上的每张SD卡时遇到麻烦。以下功能似乎只适用于第一张SD卡......

function browseFiles() {    
    var sdcards = navigator.getDeviceStorages("sdcard");    
    for (var i = 0; i<sdcards.length;i++) {    
        var files = navigator.getDeviceStorage(sdcards[i].storageName);    
        if (files != null) {    
            var cursor = files.enumerate();    
            cursor.onsuccess = function () {    
                var file = this.result;
                if (file != null) {    
                    console.log("  file : " + file.name);    
                } else {    
                     this.done = true;    
                }
                if (!this.done) {    
                    this.continue();
                }
            }    
            cursor.onerror = function () {    
                console.log("enumerate onerror");    
            }    
        }    
    }    
}

设备:中兴开放C,Firefox OS 1.3

0 个答案:

没有答案