Java Reference
In-Depth Information
Figure 8-1. Private and shared record stores between MIDlet suites
Managing Record Stores
The RecordStore class serves two purposes. First, it defines an API for manipulating individual
records. Second, it defines an API (mostly static methods) for managing record stores.
Opening, Closing, and Removing Record Stores
To open a record store, you simply need to name it.
public static RecordStore openRecordStore(String recordStoreName,
boolean createIfNecessary) throws RecordStoreException,
RecordStoreFullException, RecordStoreNotFoundException
If the record store does not exist, the createIfNecessary parameter determines whether a new
record store will be created or not. If the record store does not exist, and the createIfNecessary
parameter is false , then a RecordStoreNotFoundException will be thrown.
The following code opens a record store named “Address”:
RecordStore rs = RecordStore.openRecordStore("Address", true);
The record store will be created if it does not already exist.
An open record store can be closed by calling the closeRecordStore() method. As with
anything that can be opened and closed, it's a good idea to close record stores when you're
finished with them. Memory and processing power are in short supply on a small device, so
Search WWH ::




Custom Search