06-26-2012 06:41 PM
I have various pieces of data that I successfully store in Prefs (PersistentObject and Hashtable). Currently I am only storing Strings and Integers (Which I convert to strings). I want to start storing encrypted data (byte[]) in the Preferences. What is the best way to implement? I'm drawing a blank on searches and I want to make sure my implementation doesn't just work today but then fails two months down the road.
Thanks in advance!
Solved! Go to Solution.
06-26-2012 07:31 PM
Byte array is persistable as is. Can you not just add it as an entry in your HashTable?
06-26-2012 09:36 PM
Yeah, I thought about that on my dinner break. Since I'm a newbie, I wasn't real sure so I 'searched' but didn't see and outright example. The preference example I implemented in my app was one I found on the forums a while back and it has served me well with just strings and integers. I'll be playing with it shortly and post my results. Thanks!
06-27-2012 03:06 AM
Peter,
I did more due diligence and got it to work as you suggested. As a new newbie, (I don't have much experience using HashTables even in my Android development).
Thanks for the nudge!
06-27-2012 04:35 AM
I recommend them, even in Android development, though I think you typically use a different collection class, the Map, in Android. Map is not available on BlackBerry.
If you are considering Hashtables in this way, can I recommend thst you use the IntHashtable - this says creating a new Object just for the Key. Avoiding Objects, especially in persisted store, is a good thing.
06-27-2012 05:17 AM
I've only got 2 years Java exeperience. I'm a 10+ year VB developer normally. Nobody at our office wanted to learn Java so I was 'selected'.I'm still learning all the different 'critters' it supports. Thanks for the tip. I'll make it a point to improve on them!