I'm moving from Air/Actionscript to WebWorks and having some difficulty. I've tried several Phonegap file browser tutorials and samples I've found around the web but they're not working on the Playbook. I've added the access_shared permission to the config. I have an and when my app is launched it's supposed to load the directories and files into the .

My js is below:

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);
}
有帮助吗?

解决方案

I found the DIR example in KitchenSink showed me what I needed to know.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top