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
Highlighted
Contributor
Posts: 30
Registered: ‎03-30-2012
My Device: BlackBerry Bold 9000
My Carrier: airtel
Accepted Solution

PersistentStore.getPersistentObject returns null?

[ Edited ]

I am using a random key to retrieve an object form PersistentStore

 

persist = PersistentStore.getPersistentObject( KEY );

 

Works fine on the Simulator (OS 5), when i take the signed code to the device (BB OS 5.0 Bold 8900)

 

For some reason this returns null, without an exception. Subsequently any API I inoke on PersistentStore/persist returns null without an exception even when persist is null.

 

I am not sure if this is an eclipse debugger thing, but even though the debugger shows that objects are null. Null check applied in the code seems to fail, that means code sees these objects as not null. Pheww!!! how is this possible.

 

In this code persist shows up as null, so does safetyTable and orderedkeys. However, the null checks in the code fail.

 

At a later point in the code, when i try to access orderedkeys these are null again!!! Have been grappling with this issue for two days now, any pointers would be very heplful.

 

					persist = PersistentStore.getPersistentObject( KEY );
					persistOrderedKeys = PersistentStore.getPersistentObject(KEY_ORDERED_KEYS);
					safetyTable = (Hashtable)persist.getContents();
					orderedKeys = (Vector)persistOrderedKeys.getContents();
					if (safetyTable == null)
					{
						safetyTable = new Hashtable();

						persist.setContents(safetyTable);
						persist.commit();
					}
					
					if (orderedKeys==null)
					{
						orderedKeys=new Vector();
						
						if (safetyTable.size()>0)
						{
							Enumeration addressKeys = safetyTable.keys();
							while(addressKeys.hasMoreElements())
							{
								orderedKeys.addElement((String)addressKeys.nextElement());
							}
						}
						persistOrderedKeys.setContents(orderedKeys);
						persistOrderedKeys.commit();
						
					}
					

 

Developer
Posts: 19,636
Registered: ‎07-14-2008
My Device: Not Specified

Re: PersistentStore.getPersistentObject returns null?

"I am not sure if this is an eclipse debugger thing,"

 

I have had issues like this when I don't have a matching OS level for the device I am debugging on. 

Contributor
Posts: 30
Registered: ‎03-30-2012
My Device: BlackBerry Bold 9000
My Carrier: airtel

Re: PersistentStore.getPersistentObject returns null?

Thanks you saved me another sleepless night.