IO

The IO object provides the functionality to access un-sandboxed file system and other related attributes.


Code Example:
<script type="text/javascript">

function readFile() {
    // un-sandbox file system to access shared folder
    blackberry.io.sandbox = false;

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

    window.requestFileSystem(window.TEMPORARY, 1024 * 1024,
        function (fs) {
             // in order to access the shared folder,
             // config.xml must declare the "access_shared" permission
             // reference file by absolute path since file system is un-sandboxed
             fs.root.getFile(blackberry.io.sharedFolder + '/Documents/log.txt', {create: true},
                 function (fileEntry) {
                     fileEntry.file(function (file) {
                         var reader = new FileReader();

                         reader.onloadend = function (e) {
                             var txtArea = document.createElement('textarea');
                             txtArea.value = this.result;
                             document.body.appendChild(txtArea);
                         };

                         reader.readAsText(file);
                    }, errorHandler);
                 }, errorHandler);
        });
}

function errorHandler(e) {
    var msg = '';

    switch (e.code) {
    case FileError.QUOTA_EXCEEDED_ERR:
        msg = 'QUOTA_EXCEEDED_ERR';
        break;
    case FileError.NOT_FOUND_ERR:
        msg = 'NOT_FOUND_ERR';
        break;
    case FileError.SECURITY_ERR:
         msg = 'SECURITY_ERR';
         break;
    case FileError.INVALID_MODIFICATION_ERR:
         msg = 'INVALID_MODIFICATION_ERR';
         break;
    case FileError.INVALID_STATE_ERR:
         msg = 'INVALID_STATE_ERR';
         break;
    default:
         msg = 'Unknown Error';
        break;
    };

    console.log('Error: ' + msg);
}
</script>


Supported Platform(s)

- BlackBerry 10
View Supported Platform Table
APIBB5.0BB6.0BB7.0PB1.0PB2.0BB10Ripple
SDCard           Y 
home           Y 
sandbox           Y 
sharedFolder           Y 

Configuration Document Settings

To use all of the API described for this object, you must ensure the following settings are in your configuration document:

You must declare the feature element(s) below in your configuration document:

Feature IDBB5.0BB6.0BB7.0PB1.0PB2.0BB10Ripple
<feature id="blackberry.io" />           Y 

Permission Elements (PlayBook and BlackBerry 10+)
This API does not require a <permission> element to be declared in the configuration document of your BlackBerry WebWorks Application.

Properties

String SDCard
String home
Boolean sandbox
String sharedFolder

Properties

static readonly String SDCard


The full path of the SD card folder


Supported Platforms
 - BlackBerry 10

static readonly String home


The full path of the application data folder


Supported Platforms
 - BlackBerry 10

static Boolean sandbox


Whether the file system is sandboxed. It is set to true by default.
When sandbox is set to false, you must use absolute path to reference a file or directory, you can use sharedFolder, home or SDCard to construct file paths.


Supported Platforms
 - BlackBerry 10

static readonly String sharedFolder


The full path of the shared folder. In order to access this folder, you must specify the access_shared permission in config.xml


Supported Platforms
 - BlackBerry 10

Documentation generated by JsDoc Toolkit 2.4.0 on Mon Feb 11 2013 14:51:07 GMT-0500 (EST)