iOSDev
iOSDev

Reputation: 3617

Persistent Store data lost after session terminates in Blackberry application

I am using persistent stores to store data in a Blackberry application. While I create objects and store it in persistent store in same session data is saved properly. But the data is not recovered from store in next session.

How do I fix this?

My code is as follows:

static TrialStore ts = new TrialStore();
static Vector data= new Vector();

synchronized (store) {

store.setContents(data);

ts = new TrialStore();

ts .setElement(TrialStore.USERNAME, username);
ts .setElement(TrialStore.PASSWORD, password);

data.addElement(ts);

store.commit();

}

Upvotes: 1

Views: 762

Answers (1)

Marc Novakowski
Marc Novakowski

Reputation: 45398

You need to use the PersistentStore class to get and store the persistable object, for example:

Vector data = (Vector) PersistentStore.getPersistentObject(KEY).getContents();

Once you have updated the data, you can store it using:

PersistentStore.getPersistentObject(KEY).setContents(data);
PersistentStore.getPersistentObject(KEY).commit();

Upvotes: 4

Related Questions