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

Adobe AIR Development

Reply
New Contributor
Posts: 8
Registered: ‎07-14-2011
My Device: playbook app developed
My Carrier: abc

Need help with writing data to a folder created in the applicationstoragedirectory

Hey guys, my playbook app needs to store data in a folder in the applicationstoragedirectory. So the code is as follows:-

dir=File.applicationStorageDirectory.resolvePath(dirname);
dir.createDirectory();
for(var i:uint=0;i {
var bytes:ByteArray=reader.unzip(list[i]);
var fileStream:FileStream=new FileStream();
fileStream.open(dir.resolvePath(list[i].getFilename()),FileMode.WRITE);
fileStream.writeBytes(bytes,0,bytes.length);
fileStream.close();
}

Error #3001: File or directory access denied.
I have given the reqd permissions in the blackberry_tablet.xml i.e. access_shared.

P.S. I am using coltware_airxzip.swf for extract files from a zip archive which I am storing in the array list.

Developer
Posts: 6,541
Registered: ‎10-27-2010
My Device: HTC One, PlayBook, LE Z10, DE Q10
My Carrier: Verizon

Re: Need help with writing data to a folder created in the applicationstoragedirectory

"accessed_shared" only pertains to the shared directories on the device. That is not needed (nor would it hurt) when rwiting files to the app-storage area. Do you get that error if the fileStream portion of the code is commented out? In other words, is the words, is the error coming from the creation of the sub directory, the reading of the zip file (because it might be trying to create files on its own), or the writing of the files from your fileStream code?
Developer
Posts: 231
Registered: ‎05-03-2011
My Device: PlayBook V1 and proud of it :-)
My Carrier: Legs

Re: Need help with writing data to a folder created in the applicationstoragedirectory

Your for loop has syntax errors, can you paste the code again, my guess is your getting to the end of the file and reading more than you should be.

 

Also, place some trace("Directory is" + dir); statements in the code, debug it and see what you get back,  make sure things are being setup correctly.

Keep the Forum productive and useful for all. Click Kudos button if I've helped you. Select Solved to help everyone.

PlayBook qualifying app - Pandoras' Lights
Blog - CoCopia.co.uk Catch me on Twitter cocopia_apps
New Contributor
Posts: 8
Registered: ‎07-14-2011
My Device: playbook app developed
My Carrier: abc

Re: Need help with writing data to a folder created in the applicationstoragedirectory

Thanks for replying, the error is being shown at the fileStream.open()  function and not the unzipping part or the creation of the sub-directory. 

New Contributor
Posts: 8
Registered: ‎07-14-2011
My Device: playbook app developed
My Carrier: abc

Re: Need help with writing data to a folder created in the applicationstoragedirectory

I am sorry about that. The actual code that I have put is:
for(var j:uint=0;j<list.length;j++)
{...}
Sorry once again about that.
Highlighted
Developer
Posts: 231
Registered: ‎05-03-2011
My Device: PlayBook V1 and proud of it :-)
My Carrier: Legs

Re: Need help with writing data to a folder created in the applicationstoragedirectory

For loop fine, so your error is the file not being found, so place a trace statement as follows

 

trace(dir.resolvePath(list[i].getFilename());

 

rem out the fileStream commands, and check you have a correct path.

Keep the Forum productive and useful for all. Click Kudos button if I've helped you. Select Solved to help everyone.

PlayBook qualifying app - Pandoras' Lights
Blog - CoCopia.co.uk Catch me on Twitter cocopia_apps
New Contributor
Posts: 8
Registered: ‎07-14-2011
My Device: playbook app developed
My Carrier: abc

Re: Need help with writing data to a folder created in the applicationstoragedirectory

Thanks man, using the trace function saved the day for me, what happened is that there was folder in the zip archive, thats what was giving the error.