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

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.

Posts: 249
Registered: ‎11-02-2010
My Device: PlayBook
My Carrier: -
Accepted Solution

Application local data storage ?

[ Edited ]

Hello all.

  I would like to store data from within the application installed on the PlayBook.

Would anyone know where is this dedicated space and how to access it ?

The main usage would be to use a SQLite database (but not only).

(Is it possible with the simulator at all ?)



[Edit: the message is more specific]


BlackBerry Development Advisor
Posts: 172
Registered: ‎10-25-2010
My Device: Not Specified

Re: Application local data storage ?

The best place to store data for your application is in the application storage directory. You can access it with the following code.



var dbFile:File = File.applicationStorageDirectory.resolvePath( "my.db" );



If you want to bundle a database with your application and then have it writeable, you will need to copy it to this directory before writing to it. The reason being is your application directory is read-only. To access a file that was bundled in the root of your application, you could use the following. Then you could use the File copy methods to copy it to the applicaiton storage directory.



var bundledDb:File = File.applicationDirectory.resolvePath( "my.db" );



Hope that helps.



Posts: 249
Registered: ‎11-02-2010
My Device: PlayBook
My Carrier: -

Re: Application local data storage ?

[ Edited ]

Hello Julian, thanks for the answer.


Actually I've tried to use ApplicationStorage already, but I got an Error 3003: "File or directory does not exist" exception.

When I run the app. in Flash Burrito's internal simulator, there is no error: the db file is properly found.

But it looks like File.applicationStorage is not found on the PlayBook Simulator.


Is there a simple test to check the correct path for the App Storage ?



[Edit 1]

Some news: I could check that the ApplicationStorageDirectory path is finally ok (properly created in the PlayBook Sim.)

The problem actually comes from the ApplicationDirectory, where I search for the "source" file to load into the dbFile.


So the command "File.applicationDirectory.resolvePath("assets/MyFile.ext");" return something like:


(the XXXXXXXXXX looks to be the serial ID of the deployed project)

And so this file "does not exist" when I access it.

(reminder: it works fine in the internal Flash simulator)


Is there a simple test to check the correct path for the deployed App. ?

(still searching...)


[Edit 2]

Well, it looks like the solution was related to the (non) embedded file when deploying.

So I included the file I need (an xml file) in the deploying command line, and it was found properly on the PlayBook, using ApplicationDirectory (as described by Julian).


Just to notice, I first tried to include the full "assets" directory, with a resulting error:

at java.io.ByteArrayOutputStream.write(Unknown Source)
at com.qnx.bbt.deploy.Deploy.readPackage(Deploy.java:173)
at com.qnx.bbt.deploy.Deploy.verifyPackageId(Deploy.java:138)
at com.qnx.bbt.deploy.Deploy.sendRequest(Deploy.java:124)
at com.qnx.bbt.deploy.Deploy.run(Deploy.java:100)
at com.qnx.bbt.deploy.Deploy.main(Deploy.java:73)
at com.qnx.bbt.airpackager.BarAirPackager.callLauncher(BarAirPackager.java:206)
at com.qnx.bbt.airpackager.BarAirPackager.run(BarAirPackager.java:129)
at com.qnx.bbt.airpackager.BarAirPackager.main(BarAirPackager.java:78)
Error: null

 (It may be related to a specific file inside assets....or to the size of the directory... but it's not a big deal)




So, finally resolved. The final word would be: don't forget to include the "assets" files you need ! Smiley Happy