Many Java applications use RMS by storing just one record into each record store. This approach makes finding a certain record very quick, and porting the application from other platforms is simple as the usage pattern mimics file access. However, this approach can lead to a few hundred record stores being created on a device, resulting in an inefficient RMS usage pattern where the same record store is opened and closed repeatedly.
The PersistentStorage MIDlet demonstrates four different approaches to using RMS and allows the user to measure the efficiency of each:
The record store is kept open between get operations (basic approach).
The record store is opened for every get and set operation (bad approach, not recommended).
The record store is used with caching (caching approach).
A file-based record store is used with the FileConnection API (file approach).
The MIDlet measures how long it takes to read 100 records with each approach. To run the RMS test and see the results, select Run.
The following figure shows an example of the results that the RMS test produces.
Figure: PersistentStorage test results view
For instructions on how to implement the MIDlet, see section Implementation.