O'Reilly logo

BlackBerry Java Application Development by Bill Foust

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Time for action - accessing the PersistentObject data

  1. Modify the code you just added to add the call to setContents in the if statement to match the following code.
    if (JournalStoreObject.getContents() == null)
    {
    _EntryList = new Vector();
    JournalStoreObject.setContents(_EntryList);
    }
    else
    {
    _EntryList = (Vector)JournalStoreObject.getContents();
    }
    
  2. Next, add the call to commit to the onClose method.
    JournalStoreObject.commit();
    

What just happened?

These two calls are all that is needed to save your data to the PersistentStore. The call to the commit method was placed into the onClose method because we want to save the data when the application exits, but it doesn't have to be. You may have a good reason to call the commit method in the middle of your ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required