1. Modify the code you just added to add the call to
setContents
in theif
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 theonClose
method.JournalStoreObject.commit();
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 application for some reason and there is no problem in doing so.
The call to setContents
also requires a little explanation. Notice that the call to the setContents
method is made only in one of the two branches of the if
statement. If the...