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
Contributor
garfield9791
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();
						
					}
					

 

Please use plain text.
Developer
peter_strange
Posts: 19,595
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. 

Please use plain text.
Contributor
garfield9791
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.

Please use plain text.