If you are using Internet Explorer, please remove blackberry.com from your compatibility view settings.

Welcome!

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

Reply
Developer
ProfHawking
Posts: 46
Registered: ‎02-16-2011
My Device: 8300>9000>9700>9900>Z10
My Carrier: Vodafone

Playbook - local file access

I need to read/write to a local file to save app settings on the playbook.

 

I've had no luck using the standard webworks APIs as below:

 

 

// save to the settings file
function settings_save(string){    
    alert("writing "+string+" to file...");
    if (blackberry.io.file.exists(settings_filePath)) {
        alert("file exists, deleting..");
        blackberry.io.file.deleteFile(settings_filePath);
        alert("deleted file");
    }
    alert("converting to blob..");
    var blob = blackberry.utils.stringToBlob(string);
    alert("created blob: "+blob+"\nSaving to file..");
    blackberry.io.file.saveFile(settings_filePath, blob);
    alert("done");
}


// read from the settings file
function settings_read(){
    alert("reading file...");
    if (blackberry.io.file.exists(settings_filePath)) {
        // file exists so load its contents
        blackberry.io.file.readFile(settings_filePath, function(filepath, data){
            return blackberry.utils.blobToString(data);
        });
    } else {
        //file does not exist so display that to the user
        alert("Error: Could not find settings file!");
    }
    alert("done");
}

 

 

Is this simply because the APIs are not loaded on the Playbook, or am i doing something wrong?

 

If the file API is not available, what is the recommended way of reading from and saving to a local file?

 

Thanks!

Rob

Please use plain text.
Contributor
ImranNathani
Posts: 14
Registered: ‎02-14-2011
My Device: Not Specified

Re: Playbook - local file access

The API does not provide local file access.

You are reffering to the widget development API ...pls use tablet API ref

http://www.blackberry.com/developers/docs/webworks/api/playbook/

Please use plain text.
Developer
ProfHawking
Posts: 46
Registered: ‎02-16-2011
My Device: 8300>9000>9700>9900>Z10
My Carrier: Vodafone

Re: Playbook - local file access

Cheers, yes for now no local file access :smileysad:

 

But i've ended up using the html5 localStorage method instead for saving settings, works nicely.

Please use plain text.
BlackBerry Development Advisor
tneil
Posts: 3,708
Registered: ‎10-16-2008
My Device: Z10
My Carrier: Rogers

Re: Playbook - local file access

File access is on the way for the PlayBook too.. the team is working on this right now actually :smileyhappy:

Tim Neil
Director, Application Platform & Tools Product Management
Follow me on Twitter
Please use plain text.
Developer
TheMarco
Posts: 669
Registered: ‎02-19-2011
My Device: BlackBerry PlayBook 32GB
My Carrier: Sprint

Re: Playbook - local file access

Any idea when we'll have read/write local file access?

 

I need it to take my app to a next level :smileyhappy:

Staff UI Prototyper (read: full-time hacker)


My BB10 apps: Screamager | Scientific RPN Calculator | The Last Weather App

Please use plain text.
BlackBerry Development Advisor
tneil
Posts: 3,708
Registered: ‎10-16-2008
My Device: Z10
My Carrier: Rogers

Re: Playbook - local file access

We are currently actively working on the file access API for PlayBook.  It won't be in the upcoming Beta 3 but will likely find its way into the release after that.

 

You can monitor the latest upstream code in github.. It should show up there before it officially releases https://github.com/blackberry/WebWorks-TabletOS/tree/rtm

 

If you are looking for data storage you can also take advantage of the SQLite DB API.

Tim Neil
Director, Application Platform & Tools Product Management
Follow me on Twitter
Please use plain text.
New Developer
cicube
Posts: 6
Registered: ‎05-06-2009
My Device: Not Specified

Re: Playbook - local file access

Is local file access supported in the latest release (as of today) WebWorks SDK 2.0?

Please use plain text.
BlackBerry Development Advisor
tneil
Posts: 3,708
Registered: ‎10-16-2008
My Device: Z10
My Carrier: Rogers

Re: Playbook - local file access

local file access isn't in 2.0. it didn't make the cut unfortunately. we are continuing to work on it. For those simply looking to store data with your application and don't specifically need file access.. you can use the html5 sqlite database functionality
Tim Neil
Director, Application Platform & Tools Product Management
Follow me on Twitter
Please use plain text.
New Member
sadithe
Posts: 1
Registered: ‎05-03-2011
My Device: Playbook
My Carrier: none

Re: Playbook - local file access

Hi 

 

 Is there any Workaround to access PDFs  from local ? 

Please use plain text.
Developer
interfaSys
Posts: 817
Registered: ‎11-19-2009
My Device: Z10, Q10, 9900, 9790, PlayBook,
My Carrier: T-Mobile UK, Three, O2, Orange, Sunrise, Swisscom

Re: Playbook - local file access

The problem with localstorage and sqlite is that everything is gone if the user clears the cache.

Is the cache also deleted after an OS update?

--
Olivier - interfaSys ltd
Developing for BlackBerry 10 devices using the Sencha Touch framework.
Please use plain text.