11-02-2010 03:17 PM - edited 11-02-2010 05:42 PM
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]
Solved! Go to Solution.
11-02-2010 07:15 PM
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.
11-03-2010 09:42 AM - edited 11-03-2010 11:32 AM
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 ?
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/MyF
(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. ?
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)
(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 !