1
我正在從Air/Actionscript移動到WebWorks並且遇到一些困難。我已經嘗試了幾個我在網絡上發現的Phonegap文件瀏覽器教程和示例,但他們不在Playbook上工作。我已將access_shared權限添加到配置中。我有一個和當我的應用程序啓動它應該加載目錄和文件到。黑莓Webworks/Phonegap文件瀏覽器
我的JS低於:
document.addEventListener("deviceready", onDeviceReady, false);
function onDeviceReady(){
window.requestFileSystem(
LocalFileSystem.PERSISTENT,
0, onFileSystemSuccess, fail
);
}
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);
}