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


Thank you for visiting the BlackBerry Support Community Forums.

BlackBerry will be closing the BlackBerry Support Community Forums Device Forums on April 1st (Developers, see below)

BlackBerry remains committed to providing excellent customer support to our customers. We are delighted to direct you to the CrackBerry Forums, a well-established and thorough support channel, for continued BlackBerry support. Please visit http://forums.crackberry.com or http://crackberry.com/ask. You can also continue to visit BlackBerry Support or the BlackBerry Knowledge Base for official support options available for your BlackBerry Smartphone.

"When we launched CrackBerry.com 10 years ago, we set out to make it a fun and useful destination where BlackBerry Smartphone owners could share their excitement and learn to unleash the full potential of their BlackBerry. A decade later, the CrackBerry community is as active and passionate as ever and I know our knowledgeable members and volunteers will be excited to welcome and assist more BlackBerry owners with their questions."

- Kevin Michaluk, Founder, CrackBerry.com

Developers, for more information about the BlackBerry Developer Community please review Join the Conversation on the BlackBerry Developer Community Forums found on Inside BlackBerry.


Reply
Contributor
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!

Developer
Posts: 17,025
Registered: ‎07-29-2008
My Device: Z10 LE, Z30, Passport
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
Highlighted
Contributor
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.
Developer
Posts: 17,025
Registered: ‎07-29-2008
My Device: Z10 LE, Z30, Passport
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
Contributor
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.