Question

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);
}
Was it helpful?

Solution

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

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top