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. New to the forum? Please visit the ‘Getting Started’ link below.
inside custom component

Java Development

Reply
Contributor
ogiprayogo
Posts: 24
Registered: ‎02-10-2010
My Carrier: XL
Accepted Solution

key in persistentStore

Hi all,

 

Apologize for such a newbie question. I am reading the "PersistentStorage" tutorial and everyhing is clear to me except one thing.

private static long key = 0xdec6a67096f833cL;
	
static {
	_objStore = PersistentStore.getPersistentObject(key);
	synchronized(_objStore){
		if (_objStore.getContents() == null ){
			_objStore.setContents(new Vector());
			_objStore.commit();
		}
	}
	_data = (Vector) _objStore.getContents();
}

 

 

Where do you get/obtain key? Is is something that you must generate beforehand? If it is, how to generate? There is absolutely no info on this key on the tutorial.. it's just there...

 

 

OPrayogo
Please use plain text.
Developer
Ted_Hopp
Posts: 1,304
Registered: ‎01-21-2009

Re: key in persistentStore

Pick a string that's likely to be unique (say, the fully qualified name of your application's main class). Type it into a comment (to keep Eclipse from complaining):

// com.example.blackberry.MyApp

Then highlight the string, right click, and select "Convert String to Long" from the menu. Now you'll have a key. You might want to write a second line of comments to document where it came from. :smileyhappy:

 

I forgot where I learned this, but it was from the RIM documents somewhere. I agree that it isn't documented where you're likely to be reading when you need it (like the API docs for PersistentStore).




Solved? click "Accept as solution". Helpful? give kudos by clicking on the star.
Please use plain text.
Contributor
ogiprayogo
Posts: 24
Registered: ‎02-10-2010
My Carrier: XL

Re: key in persistentStore

[ Edited ]

Wheew! Thank you. Exactly what I need.

 

I am sure a lot of other people were looking for this as well..

OPrayogo
Please use plain text.