Creating a new RecordStore
is a pretty simple operation. However, because we're going to create a new one each time the application is closed we also have to delete any previous record stores that might have been created already. This will all be done in the onClose
method of the JournalMainScreen
, which is called when the application is quitting.
1. Add the following method to the
JournalMainScreen
class:protected void SaveEntriesRMS(Vector EntryList) throws RecordStoreNotOpenException, RecordStoreFullException, RecordStoreException { //Delete the existing recordstore if there is one. try { RecordStore.deleteRecordStore("JournalEntries"); } catch (RecordStoreException e1) { // Do nothing. It's entirely possible that the recordstore doesn't exist // yet and will throw an exception. Just silently ignore it. } // create a new one. RecordStore JournalStore = RecordStore.openRecordStore( "JournalEntries", true); if (JournalStore == null)...