Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Web and WebWorks Development

Posts: 125
Registered: ‎10-02-2011
My Device: Playbook
My Carrier: none

PhoneGap Camera Files

I'm trying to figure out how to list the files that are in the camera folder. I'm looking mostly at the File API on PhoneGap, but maybe it's not possible to do it with this. Can someone point me in the right direction?


<script type="text/javascript" src="cordova.js"></script> 
<script type="text/javascript" charset="utf-8">
// Wait for Cordova to load
document.addEventListener("deviceready", onDeviceReady, false);
// Cordova is ready
function onDeviceReady() {
	//request the file system
	window.requestFileSystem(LocalFileSystem.PERSISTENT, 0, onFileSystemSuccess, fail);
function onFileSystemSuccess(fileSystem) {
	//move to camera folder
	//list the files
function fail(evt) {


Posts: 71
Registered: ‎09-19-2012
My Device: No sleep til BlackBerry 10
My Carrier: Bell

Re: PhoneGap Camera Files

This looked promising:




So, I suppose once you have the root of the filesystem as you do in your code snippet, you could do the following:


fileSystem.root.getDirectory(blackberry.io.sharedFolder + '/camera', { create: false }, function(dir) {

    dir.createReader().readEntries(successFN, failFN);



You'll need to include the blackberry.io extension to obtain the shared directory (or, you can substitute it with '/accounts/1000/shared' but that's not recommended).


Hope this helps point you in the right direction Smiley Happy




-_- zZZ
Posts: 125
Registered: ‎10-02-2011
My Device: Playbook
My Carrier: none

Re: PhoneGap Camera Files

[ Edited ]

I'm still not able to get the contents of the camera directory. Any ideas? 


Update: This code is working.


// un-sandbox file system to access shared folder
blackberry.io.sandbox = false;

window.requestFileSystem = window.requestFileSystem || window.webkitRequestFileSystem;

window.requestFileSystem(LocalFileSystem.PERSISTENT, 0, function(fs) {
    fs.root.getDirectory(blackberry.io.sharedFolder + '/camera', {
        create: false
    }, function(dir) {
        dir.createReader().readEntries(function success(entries) {
            var i;
            for (i = 0; i < entries.length; i++) {
        }, function fail(error) {
            alert("Failed to list directory contents: " + error.code);