BlackBerry Forums Support Community

Closed Thread
LinkBack Thread Tools
Old 09-07-2009, 10:22 AM   #1 (permalink)
New Member
newbie_bb's Avatar
Join Date: Aug 2009
Model: 8300
Carrier: simulator
Posts: 9
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default Error while persisting the data in mobile phone ..

Please Login to Remove!

Hi All,
I am facing problem while persisting my data.
I followed the example provided at
http :// /developers/resources/A13_Storing_Persistent_Data_V2.pdf

First i copy paste the code in a project. It was working fine. Later I re managed the code for my use as follows.

Intially it was running fine, but even at that time it was not saving the data. Later, some how my eclipse was not able to attach to the simulator debugger.

Later after a fresh installation it worked without error but was not saving the data. Again my luck gives a shock,debugger gives a problem and
Configuration config = StoreConfiguration.getConfiguration(); of starts throwing null pointer exception.

Please let me know where I am wrong.

Class one

package com.persistence;

import net.rim.device.api.ui.component.ButtonField;
import net.rim.device.api.ui.component.CheckboxField;
import net.rim.device.api.ui.component.Dialog;
import net.rim.device.api.ui.container.MainScreen;

public class Settings extends MainScreen

	public static String mostPopular = "mostpopular";
	public static String newlyadded = "newlyadded";
	public static String news = "news";
	CheckboxField chkMostPopular;
	CheckboxField chkNewlyAdded;
	CheckboxField chkNews;
	ButtonField saveFields;

	public Settings()
			Configuration config = StoreConfiguration.getConfiguration();
			if(config != null)
				chkMostPopular = new CheckboxField("Most Popular", ((Boolean)config.getElement(mostPopular)).booleanValue());
				chkNewlyAdded = new CheckboxField("Newly Added", ((Boolean)config.getElement(newlyadded)).booleanValue());
				chkNews = new CheckboxField("News", ((Boolean)config.getElement(news)).booleanValue());
				chkMostPopular = new CheckboxField("Most Popular", false);
				chkNewlyAdded = new CheckboxField("Newly Added", false);
				chkNews = new CheckboxField("News", false);
			saveFields = new ButtonField("Save")
				protected boolean navigationClick(int status, int time)
					Dialog.alert("Data saved");
					return super.navigationClick(status, time);
		catch (Exception e)
			System.out.println("##### Error occurred Settings() "+e.getMessage());
	private void persistConfigurationData()
		Configuration config = new Configuration();
		config.setElement(mostPopular,new Boolean(chkMostPopular.getChecked()));
		config.setElement(newlyadded,new Boolean(chkNewlyAdded.getChecked()));
		config.setElement(news,new Boolean(chkNews.getChecked()));
		System.out.println("Going to persist object");
Class Second:

package com.persistence;

import java.util.Hashtable;

import net.rim.device.api.util.Persistable;

public class Configuration implements Persistable
	private static Hashtable _config;
	public Configuration()
		_config = new Hashtable();
	public Object getElement(String key)
		return _config.get(key);
	public void setElement(String key, boolean value)
		_config.put(key, new Boolean(value));
	public void setElement(String key, Boolean value)
	public Hashtable getConfiguration()
		return _config;
	public boolean isEmpty()
		return _config.isEmpty();
Class Third:

package com.persistence;

import net.rim.device.api.system.PersistentObject;
import net.rim.device.api.system.PersistentStore;

public class StoreConfiguration
	private static PersistentObject store;
	private static Configuration _data;
	public StoreConfiguration()
		//store = PersistentStore.getPersistentObject(0xdec7a67096f833cL);
		store = PersistentStore.getPersistentObject(0xe63e08aacd575338L);
		_data = new Configuration();
	public static Configuration getConfiguration()
			Object storedObject = store.getContents();
			if(storedObject == null)
				System.out.println("getConfiguration  ## _data is empty.");
				_data = (Configuration) store.getContents();
		return _data;
	public static void setConfiguration(Configuration configuration)
		System.out.println("setConfiguration  ## Going to persist object");
		_data = configuration;
		System.out.println("setConfiguration  ## _data "+((Boolean)_data.getElement("mostpopular")).booleanValue());
		synchronized (store)
Please let me know where i am going wrong ......

Thanks in advance ..

Closed Thread

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Onset T-VER-PXU-L, Differential Air Pressure Transducer Sensor
Onset T-VER-PXU-L, Differential Air Pressure Transducer Sensor picture0.5-4.5V -100~0KPa Atmospheric Pressure Sensor Transducer Module
0.5-4.5V -100~0KPa Atmospheric Pressure Sensor Transducer Module pictureOnset T-VER-8044-100, Veris 480 V, 100 Amp Kilowatt Transducer Sensor
Onset T-VER-8044-100, Veris 480 V, 100 Amp Kilowatt Transducer Sensor pictureOnset T-WNB-3D-240, WattNode 208/240 VAC 3-phase Delta/Wye kWh Transducer Sensor
Onset T-WNB-3D-240, WattNode 208/240 VAC 3-phase Delta/Wye kWh Transducer Sensor picture Acuson-7-L7-Ultrasound-Transducer-Probe
 Acuson-7-L7-Ultrasound-Transducer-Probe   picture

Copyright 2004-2016
The names RIM and BlackBerry are registered Trademarks of BlackBerry Inc.