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
Super Contributor
SumiGhosh
Posts: 306
Registered: ‎09-20-2011
My Carrier: Vodafone

Persistence store not working properly in simulator

private void setDataPersistently(Userinfo infoData){
     store = PersistentStore.getPersistentObject(0x2562651c36cbeb75L);
     UserInfo info = new UserInfo();
     info.setUsername(infoData.getUsername);
     info.setPassword(infoData.getPassword);
     store.setContents(info);
     store.commit();
}

 

public UserInfo getUserInfo() {
    UserInfo userInfo = new UserInfo();
    userInfo = (UserInfo)store.getContents();
      if(userInfo == null) {
          userInfo = new UserInfo();
          userInfo.setUsername("");
          userInfo.setPassword("");
    }
return userInfo;
}

 

I'm getting null as return value for userInfo.

 


public class UserInfo implements Persistable {
private String username;
private String password;
public String getUsername() {
return username;
}
public void setUsername(String message) {
this.password = message;
}
public String getPassword() {
return username;
}
public void setPassword(String message) {
this.password = message;
}
}

 

Please use plain text.
Developer
peter_strange
Posts: 17,701
Registered: ‎07-14-2008

Re: Persistence store not working properly in simulator

I suspect that store is null when you do the get - I would suggest that you add

store = PersistentStore.getPersistentObject(0x2562651c36cbeb75L);

before

userInfo = (UserInfo)store.getContents();

 

Couple of codding things

1) You do not need the

UserInfo userInfo = new UserInfo();

before

userInfo = (UserInfo)store.getContents();

2) Check your setUsername and getPassword methods. 

Please use plain text.