List of all Iphone and Blackberry Development codes in a one click Iphone,objective C,xcode,blackberry Development,iOS Development

Thursday, June 27, 2013

Creating a persistent store in Blackberry

To create a persistent store, you create at least one PersistentObject. Each PersistentObject has a unique key of type long.

Creating Store - 
static PersistentObject store;
static {
store = PersistentStore.getPersistentObject( 0xa1a569278238dad2L );
}
 
Insert datas to store -  
String[] userinfo = {username, password};
synchronized(store) {
store.setContents(userinfo); 
store.commit();
} 

Retrive datas from store -
synchronized(store) {
String[] currentinfo = (String[])store.getContents(); 
if(currentinfo == null) {
Dialog.alert(_resources.getString(APP_ERROR));
} 
else {
currentusernamefield.setText(currentinfo[0]);
currentpasswordfield.setText(currentinfo[1]);
}
}

1 comment: