尝试浏览手机上的每张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