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
ftt
Contributor
ftt
Posts: 10
Registered: ‎02-24-2012
My Device: none
Accepted Solution

Using setControlledAccess in WebWorks

I'm trying to use setControlledAccess in a WebWorks application. I need to download an unprotected file and save it on an SD card encrypted. I am able to create such a file, but can't write to it.

 

I've created a small JS extension (according to a tutorial) to use setControlledAccess:

final CodeSigningKey key = CodeSigningKey.get(CodeModuleManager.getModuleHandle("xxx"), "XXX");
if (key == null)
    // do something
ExtendedFileConnection file = (ExtendedFileConnection)Connector.open(fileName);
// omitted a check for file existence
file.setControlledAccess(key);
file.create();
file.close(); 

 

The file is created.

 

Next, I'm trying to write to that file via PhoneGap (download it via FileTransfer), however, that gives me a ControlledAccessException. Naturally, I've signed my COD file with the XXX key mentioned above. What's wrong?

 

I'm new to Blackberry and suspect that I've made some stupid newbie mistake but can't see it myself, unfortunately :smileysad:

BlackBerry Development Advisor
naveenan
Posts: 101
Registered: ‎10-11-2011
My Device: BlackBerry 9810

Re: Using setControlledAccess in WebWorks

Hi

Ensure that you have the write permission to the file that was just created.

Thanks

Naveen M
ftt
Contributor
ftt
Posts: 10
Registered: ‎02-24-2012
My Device: none

Re: Using setControlledAccess in WebWorks

[ Edited ]

I had necessary permissions. The problem, for some obscure reason, was in using Data(Output|Input)Stream instead of plain (Output|Input)Stream.