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
Contributor
carll70
Posts: 32
Registered: ‎10-21-2012
My Device: 9900
My Carrier: NA
Accepted Solution

SQLite, Hashtable or Other Options?

Hello. I am relatively new to BB dev.  Looking for the most effecient way of storing and querying very simply data.  A date column and a count.  Eg.

 

2012-10-01, 5

2012-10,02, 1

 

Need to be able to determine the sum of count for month of 10, 2012 for instance.  Would rather not use SQLite, would rather perhaps create a hashtable in persistent storage.  Just concerned about requirements to do things like get count by month, etc.  Seems it would require some string parsing, loopoing, etc. to get this info if in hashtable.

 

What would you recommend as the best approach?  Are there other options that I'm maybe not aware of?  Thank you!

Please use plain text.
Developer
simon_hain
Posts: 16,021
Registered: ‎07-29-2008
My Device: Z10 LE
My Carrier: O2 Germany

Re: SQLite, Hashtable or Other Options?

hashtable in persistent storage would be fine.
Date objects cannot be persisted, but you can use Long instead.
----------------------------------------------------------
feel free to press the like button on the right side to thank the user that helped you.
please mark posts as solved if you found a solution.
@SimonHain on twitter
Please use plain text.
Contributor
carll70
Posts: 32
Registered: ‎10-21-2012
My Device: 9900
My Carrier: NA

Re: SQLite, Hashtable or Other Options?

Thank you Simon. Using long is a great idea. Out of curiousity, haven't seen a method yet, is there a way to query a hash table much like querying a sqlite database? One all of my data is stored I'm concerned about the most effifient way to do things like grouping/summing counts based on long/date. In sqlite I could simply select where datepart, etc.
Please use plain text.
Developer
simon_hain
Posts: 16,021
Registered: ‎07-29-2008
My Device: Z10 LE
My Carrier: O2 Germany

Re: SQLite, Hashtable or Other Options?

a hashtable stores objects using the hash value of the key.
If you use Long as a key its hash function is provided, but if you use a custom key you have to implement hashCode and equals (eclipse has a nice comfort function for that).

regarding the grouping: you don't have a full data model so you have to write your own. hashtable functions are not that slow, so unless you are really pressed in computing time you should be fine just adding different values.
If your table should only store dates you can use http://www.blackberry.com/developers/docs/7.1.0api/net/rim/device/api/util/LongHashtable.html which should be even a bit faster.
----------------------------------------------------------
feel free to press the like button on the right side to thank the user that helped you.
please mark posts as solved if you found a solution.
@SimonHain on twitter
Please use plain text.
Contributor
carll70
Posts: 32
Registered: ‎10-21-2012
My Device: 9900
My Carrier: NA

Re: SQLite, Hashtable or Other Options?

Excellent. Thank you for the advice. Thanks a lot.
Please use plain text.