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

Java Development

Reply
New Developer
Posts: 36
Registered: ‎10-28-2009
My Device: Not Specified

How to distribute app with "preset" persistent storage

Hi,

 

I am using the native blackberry persistence api for persisting objects. Now I'd like to distribute my app with some "pre saved" objects. How can I achieve that?

 

Thanks

Highlighted
Developer
Posts: 42
Registered: ‎03-03-2009
My Device: 9600
My Carrier: Vodafone

Re: How to distribute app with "preset" persistent storage

Hi,

      From your post , it seems that you have knowledge of persistance store in BB. So you have created the database and  tables within your application. Same way you have to apply insert query immediatly after creating required tables.

 

Regards,

Tej

Tejas Barbhaya

Logistic Infotech
tej.barbhaya@gmail.com
www.logisticinfotech.com
New Developer
Posts: 36
Registered: ‎10-28-2009
My Device: Not Specified

Re: How to distribute app with "preset" persistent storage

Hi,

 

but I have a csv with 25 000 lines and 6 columns -- It takes a long time to parse the file and then inserting it to the bb persistence api.

 

Is there a possibility to say "please export the bb persistence storage", so that I can deliver that to other bb smartphones?

Developer
Posts: 562
Registered: ‎09-30-2009
My Device: Not Specified

Re: How to distribute app with "preset" persistent storage

[ Edited ]

Just check if the persistent object is null first, and then if so, put the object in memory.

 

If you're persisting a static object first, have an in-memory copy of the CSV in a data structure to begin with -- why waste time parsing from a file if you're going to stick it in memory anyway?

New Developer
Posts: 36
Registered: ‎10-28-2009
My Device: Not Specified

Re: How to distribute app with "preset" persistent storage

The CSV is about 2,5 MB big.

 

Do I understand your solution correctly, that I create a 2,5 MB huge string for the content of the csv and then parsing this String?

Developer
Posts: 19,636
Registered: ‎07-14-2008
My Device: Not Specified

Re: How to distribute app with "preset" persistent storage

It is not possible to create a persistent storage image in your application program that is installed with your application.  If your data must b ine objects in persistent store, then you do have to create the objects. 

 

If you do include the CSV file and parse it into persistent store, you have effectively taken up at least 5 MB of storage, 2.5 in your application, plus 2.5 in persistent store.  Perhaps you could look at downloading the data rather than including the data in your application? 

 

Does this data change?  Is the data just an initial configuration that will be updated over time?  If the data is static, there may be other options. 

New Developer
Posts: 36
Registered: ‎10-28-2009
My Device: Not Specified

Re: How to distribute app with "preset" persistent storage

The data is static. My plan is to change data from version to version.

At the moment I am downloading the content (zipped), extracting it and then parsing it from the filesystem.

 

But in my opinion the procedure is to slow and no user will accept the "delay" for the first use of the application.

 

Could you tell me the other options, when the data is static (my case...)

Developer
Posts: 19,636
Registered: ‎07-14-2008
My Device: Not Specified

Re: How to distribute app with "preset" persistent storage

As an example, say you need to pre-populate an array with data.  In this case, for an autofill EditField.  So you have a array that applies if the user types in an "a" for example.  In the cod, you can create a static String array, that looks something like:

 

static String [] startWithA = new String [] { "a1", "a2", "a13, .... };

 

Then you can use this array directly in your code.

 

Another options, say you have a 'table' of data.  You can simulate this in a String array, in a similar way to the above, then write a search mechanism that searches this table and pulls out the appropriate column.

 

So basically with this option you are actually creating the datastructure you want to use statically, in your code.

 

I suspect that this will not work for a lot of types of data.

 

If you can give us some idea about how you use your data we might be able to suggest options like this.

 

But the other comment I have, is since this does not need to be persistent, have you timed how long it takes to build up your Objects just in RAM?  You could do that at app start-up or device start-up, and keep this until the next app startup or device startup.  I wonder of creating non persistent objects is a lot faster, I suspect it would be.  In which case it might be better to do it frequently and throw away the result?  This would actually be lower impact on the user, since RAM memory is not restricted as flash.

New Developer
Posts: 36
Registered: ‎10-28-2009
My Device: Not Specified

Re: How to distribute app with "preset" persistent storage

Thank you peter,

 

that's an awesome idea. I keep the complete data in a Collection in the RAM, so I don't need the persistence for that.

 

I will test that!

New Developer
Posts: 36
Registered: ‎10-28-2009
My Device: Not Specified

Re: How to distribute app with "preset" persistent storage

Unfortunately Java does not support that huge Java-Classes. It tells me an error when building a class which is bigger than 64KB.