Java Reference
In-Depth Information
As shown in Figure 6-1, the MIDlet suites in the example application follow
these rules:
• The WizardGames MIDlet suite uses only the WizardGameHighScores record store,
which is private to WizardGames .
• The Weather and Traveller MIDlet suites each have a private record store for
configuration and other data.
• The Traveller and Weather MIDlet suites read the current weather forecasts from
the CurrentWeatherData public record store.
Of course, both the Traveller and Weather MIDlet suites must understand the
representation schema for records in the CurrentWeatherData public record store. You
can make this happen most easily by sharing a class, because code can't be shared
between MIDlets.
Record store names must be unique. To help guarantee this, the Java ME runtime
uses a MIDlet suite's name as part of the name for a record store, so that you only need to
guarantee uniqueness when naming multiple stores within your application. Note that
the names are case sensitive and represented as Unicode strings, so you can localize
them as you would any other application string (although they typically don't appear
anywhere in the user interface unless your MIDlet shows a list of its record stores).
Records within the record store are given a unique index, which is the record's
primary key. This index starts with 1 and increments so that after creating record n , the
next record you create is given the index n+1 . Removing a record does not recycle the
record ID; once a record ID is used, it's permanently assigned, even if the value to
which it's assigned is null .
Implementations of the record store must guarantee atomicity across a single thread,
but do not guarantee atomicity across multiple threads. Consequently, if your MIDlet
accesses the record store from multiple threads, be sure to synchronize access to records
in the store.
Using the Record Store
There's actually very little you can do with a record store, because most of the work you
perform is with records within a store. Consequently, you can open or close a record
store, as well as remove a record store. Finally, you can check the version of a record store,
so you can ensure that your application uses the right record representation when read-
ing records from and writing records to the store.
All of the methods in this section belong to the javax.microedition.rms.
RecordStore class.
 
Search WWH ::




Custom Search