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


Thank you for visiting the BlackBerry Support Community Forums.

BlackBerry will be closing the BlackBerry Support Community Forums Device Forums on April 1st (Developers, see below)

BlackBerry remains committed to providing excellent customer support to our customers. We are delighted to direct you to the CrackBerry Forums, a well-established and thorough support channel, for continued BlackBerry support. Please visit http://forums.crackberry.com or http://crackberry.com/ask. You can also continue to visit BlackBerry Support or the BlackBerry Knowledge Base for official support options available for your BlackBerry Smartphone.

"When we launched CrackBerry.com 10 years ago, we set out to make it a fun and useful destination where BlackBerry Smartphone owners could share their excitement and learn to unleash the full potential of their BlackBerry. A decade later, the CrackBerry community is as active and passionate as ever and I know our knowledgeable members and volunteers will be excited to welcome and assist more BlackBerry owners with their questions."

- Kevin Michaluk, Founder, CrackBerry.com

Developers, for more information about the BlackBerry Developer Community please review Join the Conversation on the BlackBerry Developer Community Forums found on Inside BlackBerry.


Reply
Contributor
Posts: 16
Registered: ‎04-26-2011
My Device: Bold 9780
My Carrier: Vodafone Spain

Writing files to SDcard from WebWorks

Hi,

 

I was wondering how to write files from a WebWorks app to the SD card or internal storage. Looking at the API there seems to be something that enables me to write to SD:

 

var filePath = "file:///SDCard/BlackBerry/Sample.txt";

var blob_data = blackberry.utils.documentToBlob(testData);

blackberry.io.file.saveFile(filePath, blob_data);

 

I also added the following to config.xml:

 

file:///SDCard/BlackBerry

 

Any idea why it isn't working?

 

By the way, what is a blob???

 

Regards

Developer
Posts: 151
Registered: ‎02-19-2011
My Device: Bold 9930 and PlayBook

Re: Writing files to SDcard from WebWorks

Did you figure this out yet? 

"Not to know what happened before you were born is to be forever a child." Marcus Tullius Cicero
Retired
Posts: 3,708
Registered: ‎10-16-2008
My Device: Z10
My Carrier: Rogers

Re: Writing files to SDcard from WebWorks

Which OS version are you trying these calls?

 

BlackBerry 5.0, 6.0 or PlayBook?

 

BlackBerry 6.0 does not support the documentToBlob() function

Tim Neil
Director, Application Platform & Tools Product Management
Follow me on Twitter
Developer
Posts: 151
Registered: ‎02-19-2011
My Device: Bold 9930 and PlayBook

Re: Writing files to SDcard from WebWorks

I'm looking to do WebWorks for OS 6.0 and Playbook.  I just heard that at least for Playbook the feature will be available in mid-June.

"Not to know what happened before you were born is to be forever a child." Marcus Tullius Cicero
Retired
Posts: 3,708
Registered: ‎10-16-2008
My Device: Z10
My Carrier: Rogers

Re: Writing files to SDcard from WebWorks

Yes, file I/O will be coming to WebWorks on PlayBook in a week or two.  However, documentToBlob and blobToDocument are only supported on BB5

Tim Neil
Director, Application Platform & Tools Product Management
Follow me on Twitter
Developer
Posts: 151
Registered: ‎02-19-2011
My Device: Bold 9930 and PlayBook

Re: Writing files to SDcard from WebWorks

Ok, so I was trying to access a file in the Playbook simulator but it didn't work.  The simulator is 1.0.1 and the SDK is the version released just a week or two ago. 

The code is below:

var filePath = blackberry.io.dir.appDirs.app.storage.path + "/favorites.txt";
	function onFileOpen(fullPath, blobData){
	      globalBlob = blobData;
	      alert(globalBlob);
	}
	alert(filePath);
	if (blackberry.io.file.exists(filePath)) {
	    try{
			blackberry.io.file.readFile(filePath,onFileOpen, true);
		}catch(e){
	      alert(e);
		}
	}
	else {
		var globalBlob = "TEST";
		blackberry.io.file.saveFile(filePath, globalBlob);
	}

 

"Not to know what happened before you were born is to be forever a child." Marcus Tullius Cicero
Highlighted
Developer
Posts: 151
Registered: ‎02-19-2011
My Device: Bold 9930 and PlayBook

Re: Writing files to SDcard from WebWorks

Looks like I found my answer:

http://supportforums.blackberry.com/t5/Web-and-WebWorks-Development/BlackBerry-WebWorks-SDK-2-1-for-...

This feature isn't supported yet! 

 

"Not to know what happened before you were born is to be forever a child." Marcus Tullius Cicero