Java Reference
In-Depth Information
SecurityException : Indicates that the operation cannot be completed because the
MIDlet has read-only access to the record store
RecordStoreException : Indicates a general failure related to the open record store
The word delete in the interface name is a bit of a misnomer. You have no control
over how the record store manages removal; record store compaction may occur on a
removal operation, or it may not. Moreover, the interface does not recycle the ID assigned
to the deleted record; once a record is deleted, the ID remains used. Querying for that ID
returns a null record or an exception indicating an invalid record ID.
Counting Records
If you're getting ready to preprocess a large number of records, you may want to know
how many records are in the record store. Of course, you can do this with an enumera-
tion and counter, but there's an easier way: simply invoke getNumRecords on an open
record store. It either returns an integer indicating the number of records currently in the
record store, or throws the RecordStoreNotOpenException if the record store isn't open.
Listening for Record Store Changes
At times, you may want one application to respond to changes from another applica-
tion. The record store's addRecordListener and removeRecordListener methods do just
that, letting you register a listener that implements the RecordListener interface on an
open record store, and deregister a listener, respectively. Once added, a record listener
receives the following method invocations whenever a record is added, changed, or
deleted, as follows:
recordAdded : The system invokes this method when a record is added.
recordChanged : The system invokes this method when a record is changed.
recordDeleted : The system invokes this method when a record is deleted.
All three of these methods take two parameters: a reference to the record store in which
the record is stored, and the record ID of the record being added, changed, or deleted.
Understanding Platform Limitations of Record Stores
Record stores are a good compromise for the variety of mobile devices that can support Java
ME. However, they're not perfect—or, more to the point, as you work with them, you learn
that their implementation on different devices can be far from perfect. If you're deploying a
Java ME application to run on many devices, odds are you will encounter two pitfalls.
 
Search WWH ::




Custom Search