简体   繁体   English

Blackberry Webworks / Phonegap文件浏览器

[英]Blackberry Webworks/Phonegap file browser

I'm moving from Air/Actionscript to WebWorks and having some difficulty. 我正在从Air / Actionscript迁移到WebWorks,并且遇到了一些困难。 I've tried several Phonegap file browser tutorials and samples I've found around the web but they're not working on the Playbook. 我已经尝试了一些在网络上找到的Phonegap文件浏览器教程和示例,但是它们不适用于Playbook。 I've added the access_shared permission to the config. 我已将access_shared权限添加到配置中。 I have an and when my app is launched it's supposed to load the directories and files into the . 我有一个,启动我的应用程序时,应该将目录和文件加载到中。

My js is below: 我的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);
}

我发现KitchenSink中的DIR示例向我展示了我需要知道的内容。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM