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
Highlighted
Developer
Posts: 19,636
Registered: ‎07-14-2008
My Device: Not Specified

Re: Problem in persistent value

[ Edited ]

Are you using the cleaner implementation that Nate posted here:

 

http://pastebin.com/tka4jQvF

 

Whether you are or not, you can not just paste that code into your application and use it.  You have to create a key for the PersistentStore Object first - that gives you the Hashtable.  Then you have to use a key on the Hashtable to get the actual values you are persisting.  So you can't be using the code supplied, you must have tailored it in some way. 

 

I am getting the impression that you are not sure how to use PersistentStore.  I recommend that you review the KB articles and documentation that is available, including these:

 

http://developer.blackberry.com/bbos/java/documentation/persistentstore_intro_1981761_11.html

 

http://supportforums.blackberry.com/t5/Java-Development/Storing-Persistent-Data/ta-p/442785

 

http://supportforums.blackberry.com/t5/Java-Development/Best-Practices-for-Persistent-Store/ta-p/115...

 

Having reviewed these, I recommend you revisit the example you have found, and see if you understand what it is actually doing. 

 

I don't use exactly the same approach as suggested by Nate, but it is very similar to it.  The important aspects are:

1) access to the persisted data is managed through one class,

2) the persisted data is managed in a collection rather than a single item, and

3) any class wanting to access some data that is persisted identifies the persisted data it wants by specifying a 'lookup' key.