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
Developer
tensioncore
Posts: 323
Registered: ‎12-13-2010
My Device: Bold 9900/Z10 Special Edition
My Carrier: Rogers
Accepted Solution

Lots of Data- What to do?

Okay, so I need to have about 200 Paragraphs of information stored in my app for use at any given time, and I'm wondering what would be smarter?

 

Store the paragraphs in SQLite? Or Hard-code the paragraphs into variables in the app?

 

This information will NOT be used in equations, and will be used 1 at a time.

CEO/Lead Developer - Tensioncore™ Design Studios
http://tncr.ws/ - ShortenThis!™ for Blackberry Playbook | ShortenThis!™ for BlackBerry® 10
The Periodical Toe A highly informative Table of Elements
DrawThis! A fun drawing app for the BlackBerry® PlayBook™!
http://www.tensioncore.com/ - Tensioncore™ Web Hosting
Please use plain text.
Regular Contributor
L7ColWinters
Posts: 82
Registered: ‎11-12-2010
My Device: Android Droid Incredible
My Carrier: Verizion

Re: Lots of Data- What to do?

Store it in a file in your project that you can reference to.

Please use plain text.
Developer
jtegen
Posts: 6,541
Registered: ‎10-27-2010
My Device: HTC One, PlayBook, LE Z10, DE Q10
My Carrier: Verizon

Re: Lots of Data- What to do?

When you say "1 at a time", do you mean accessed once, use once, then discarded? If that is the case, then a database or flat file might work.  If you are going to load them all, then an XML file might be good.  Keeping that amount of state, hard coded in the application can be difficult to maintain.  If you are going to offer multiple languages, then a DB or flat files might be good too.

 

If they are all read-only, then an install in the app folder would work fine.

Please use plain text.
Developer
peter9477
Posts: 6,473
Registered: ‎12-08-2010
My Device: PlayBook, Z10
My Carrier: none

Re: Lots of Data- What to do?

Certainly not SQLite, if the app won't change them.

 

I'd probably [Embed()] them to avoid even having to do File stuff.

 

Store in one file with unique separator string, and do a String.split() to convert the whole thing to an Array at run time.

 

 

[Embed('paragraphs.txt', mimeType='application/octet-stream')]
public static const ParagraphData:Class;

...

// use a more sophisticated separator here:
var paragraphs:Array = new ParagraphData().toString().split('--separator--');

 

 


Peter Hansen -- (BB10 and dev-related blog posts at http://peterhansen.ca.)
Author of White Noise and Battery Guru for BB10 and for PlayBook | Get more from your battery!
Please use plain text.
Developer
tensioncore
Posts: 323
Registered: ‎12-13-2010
My Device: Bold 9900/Z10 Special Edition
My Carrier: Rogers

Re: Lots of Data- What to do?

@peter9477 I think this is the best idea, the information is going to be static information that will not be altered in any way by the App itself, but it will be reused. Is there a way to do matched pairs in more than just pairs? so like 3 or even 4 to a single array item?
CEO/Lead Developer - Tensioncore™ Design Studios
http://tncr.ws/ - ShortenThis!™ for Blackberry Playbook | ShortenThis!™ for BlackBerry® 10
The Periodical Toe A highly informative Table of Elements
DrawThis! A fun drawing app for the BlackBerry® PlayBook™!
http://www.tensioncore.com/ - Tensioncore™ Web Hosting
Please use plain text.
Developer
peter9477
Posts: 6,473
Registered: ‎12-08-2010
My Device: PlayBook, Z10
My Carrier: none

Re: Lots of Data- What to do?

With a more complex structure, I'd strongly consider storing and parsing the data as XML instead, but it's not hard to do that with a string either.  Just do an outer loop over the first split(), and on each chunk do another split() with a second separator to get the individual items within each "chunk".

 

I'd say anything beyond a single level of nesting would definitely warrant XML or something else like that.  (I'd look at JSON too at that point.)


Peter Hansen -- (BB10 and dev-related blog posts at http://peterhansen.ca.)
Author of White Noise and Battery Guru for BB10 and for PlayBook | Get more from your battery!
Please use plain text.
Developer
tensioncore
Posts: 323
Registered: ‎12-13-2010
My Device: Bold 9900/Z10 Special Edition
My Carrier: Rogers

Re: Lots of Data- What to do?

XML is probably the best solution. Easier to work with, I'm not a fan of JSON, that's why I've developed my own API with my web services and blog software.

 

And besides, there's a good amount of resources for working with XML!

 

Thanks!

CEO/Lead Developer - Tensioncore™ Design Studios
http://tncr.ws/ - ShortenThis!™ for Blackberry Playbook | ShortenThis!™ for BlackBerry® 10
The Periodical Toe A highly informative Table of Elements
DrawThis! A fun drawing app for the BlackBerry® PlayBook™!
http://www.tensioncore.com/ - Tensioncore™ Web Hosting
Please use plain text.
Developer
kdittyr
Posts: 278
Registered: ‎10-27-2010
My Device: Playbook

Re: Lots of Data- What to do?

[ Edited ]

I would pretty much suggest going with XML.  I have not idea what you are trying to achieve, but XML would allow you to set attributes or subnodes that would allow you to be much more specific with your data.

 

An example would be a language file for your application:

 

var my_xml:XML = new XML( <xml>
 <description>
  <english>Simple description using english</english>
  <other_language>Simple description using other language</other_language>
 </description>
 <title>
  <english>The title of the paragraph in english</english>
  <other_language>The title of the paragraph in other language</other_language>
 </title>
</xml> );

var my_language:String = 'english';

trace( my_xml.description[ my_language ] );
trace( my_xml.title[ my_language ] );

 

By changing the language variable to 'other_language' you would be accessing a totally different set of data.  I know the above is a very simplified example of a language file and it's useage...  and this might not even pertain to what you are looking for.  I do, however, hope that it helps someone.

--------------
kdittyr

Accepted PlayBook Applications:
HDB Converter -- Utilities/Calculators
Please use plain text.
Developer
tensioncore
Posts: 323
Registered: ‎12-13-2010
My Device: Bold 9900/Z10 Special Edition
My Carrier: Rogers

Re: Lots of Data- What to do?

Beautiful.

 

Yes, this is pretty much exactly the manner I'll be using the information! Thanks for the support!

CEO/Lead Developer - Tensioncore™ Design Studios
http://tncr.ws/ - ShortenThis!™ for Blackberry Playbook | ShortenThis!™ for BlackBerry® 10
The Periodical Toe A highly informative Table of Elements
DrawThis! A fun drawing app for the BlackBerry® PlayBook™!
http://www.tensioncore.com/ - Tensioncore™ Web Hosting
Please use plain text.
Developer
peter9477
Posts: 6,473
Registered: ‎12-08-2010
My Device: PlayBook, Z10
My Carrier: none

Re: Lots of Data- What to do?

I'd still recommend using Embed() with that though, so you can keep the data in an external file, but then parsing it as XML at runtime.  It might be easier to maintain or manage than doing what amounts to hardcoding it inside a source file.


Peter Hansen -- (BB10 and dev-related blog posts at http://peterhansen.ca.)
Author of White Noise and Battery Guru for BB10 and for PlayBook | Get more from your battery!
Please use plain text.