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 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 🙁
The problem, for some obscure reason, was in using
Data(Output|Input)Streaminstead of plain(Output|Input)Stream.