任何人都可以解释如何使用Android的Phonegap File API列出页面上的文件文件夹吗?
.mp3如果可能的话,我想列出所有文件,但是已经阅读了所有的phonegap文档(http://docs.phonegap.com/en/1.0.0/phonegap_file_file.md.html)并且根本无法解决它!
Sim*_*ald 11
它在@ $$中有点痛苦但可行.从这段代码开始:
document.addEventListener("deviceready", onDeviceReady, false);
// PhoneGap is ready
//
function onDeviceReady() {
window.requestFileSystem(LocalFileSystem.PERSISTENT, 0, onFileSystemSuccess, fail);
}
function onFileSystemSuccess(fileSystem) {
fileSystem.root.getDirectory("Music", {create: false, exclusive: false}, getDirSuccess, fail);
}
function getDirSuccess(dirEntry) {
// Get a directory reader
var directoryReader = dirEntry.createReader();
// Get a list of all the entries in the directory
directoryReader.readEntries(readerSuccess,fail);
}
function readerSuccess(entries) {
var i;
for (i=0; i<entries.length; i++) {
// Assuming everything in the Music directory is an mp3, go nuts
// otherwise check entries[i].name to see if it ends with .mp3
}
}
Run Code Online (Sandbox Code Playgroud)
我正在IDE之外编写所有这些示例代码,因此可能存在错误但是应该让你继续.
| 归档时间: |
|
| 查看次数: |
7252 次 |
| 最近记录: |