09-09-2009 11:39 AM
Hello all,
My app runs from a database file on the device's flash memory. While the app can download data from my server to populate the database, the first download is fairly big and takes a while to run (I'm working on that).
It occurred to me that an alternative might be to supply a pre-populated database file along with the app, so that then the app will run straight out of the box without requiring that first sync.
Does anyone know if the App World store supports this - distribution of data as well as the app?
Many Thanks...
Solved! Go to Solution.
09-14-2009 01:59 PM
Just put an text or xml file or any file format of your choice in your resources and just read it and add to the database file on the devices flash memory upon start up. This data is required upon startup, right?
09-15-2009 07:53 AM
Yes technically that would work for me, but probably not in practice. I don't believe there is a way of deleting resources, so after extracting the data file to a read/write location I would then be left with a redundant copy of the file. The database file is a few MB in size so I'd rather not have this amount of space wasted on the device. Shame as I think your idea is quite clever.
09-15-2009 09:51 AM - edited 09-15-2009 09:56 AM
You are correct about the wasted space. But how about you still include a resource file but make it so that if your program needs to read the "core" data, read from the resource file and if it is new data, read from the DB. I'm not sure what your application is doing so I don't know if this is feasible or not but if it is, this would solve your problem. What do you think?
09-15-2009 12:24 PM
I think that's probably the best way it can be done - nice diagram! ![]()
Any of my data records could potentially change with a future sync with the server, though most of them probably won't. I'll set this as the solution though as I think it'll be helpful for others.
I'm going to see whether I can section off a portion of the database as core/read-only data, then this approach will work really well.
Thanks!
07-22-2010 05:10 PM
I've got pretty much the same scenario going on. Am I to understand from this dialog that it isn't possible to write to a file that was deployed as a /res in the COD?
07-26-2010 07:23 AM
As far as I know, resource files inside the COD are read only. I ended up packaging a zipped data file inside the COD, then on first run of the app I unzip it to a read/write location (either the device store or the SD card). From then on the app just works on the read/write copy.
09-14-2010 11:15 AM
How ddid you get access to a file inside the .codFile??? I want to change my iconimage but I can´t get the imege file, it's in a folder inside my cod. --- Images/logo.png...
09-14-2010 11:25 AM
See:
http://www.blackberry.com/developers/docs/5.0.0api
I use it like this, where MyFile.zip is in the same package as MyClass.java:
InputStream is = MyClass.class.getResourceAsStream("MyFile.zip");
if (is != null) {
// Read from stream and close it
}
09-14-2010 11:37 AM
Ok, thanks for your anwer, it was so fast... (and sorry for my english). In my case i'm working with widgets because in the company we can´t use java. Do you know how to get an url inside the .cod The method i'm using is
blackberry.app.setHomeScreenIcon(
"Images/Logo.png", false);
and I get an exception: The resource could not be retrieved because it was not foun in the config.xml, it ask me to put <access> element in my xml but I don't know how because it has to be using a protocol so, <access url="/Images"></access> sends an error when i'm compiling...