RMS Basics

The RMS API is contained in the package javax.microedition.rms. A MIDlet can create and access a number of record stores. Each record store has a name that is unique in the MIDlet suite. It consists of a number of variable-length records. The records themselves are simple byte arrays without any further predefined structure.

The RMS API does not include routines for integrity maintenance. All maintenance is performed by the platform automatically.

MIDlets can access record stores of other MIDlets only if they are in the same MIDlet suite. For instance, it is possible to include a MIDlet A inside MIDlet suite 1 and include a MIDlet B in MIDlet suite 2. Although both MIDlet suites are on the same device, MIDlet A is not allowed to manipulate the log or diary information of MIDlet B because it's in a different suite. Figure 5.1 shows how the RMS maintains multiple records stores of different MIDlets.

Figure 5.1. The record store's visibility and structure.


Within a MIDlet suite, MIDlets can create record stores with case-sensitive names up to 32 Unicode characters long. Inside a MIDlet suite, the names must be unique. However, MIDlets are allowed to create record stores with the same name in different MIDlet suites. In that case, the platform is responsible for handling them as separate record stores. Additionally, the platform is responsible for deleting the record stores that are created by a MIDlet on the device when the MIDlet is deleted.

All operations on the record store are atomic. That means that if two threads write the same record in parallel, these calls are serialized by the system automatically. This process avoids corruption of the internal structure of the record store, but does not prevent the application data structure from becoming invalid: Serializing two write operations to the same record means that the second write operation overwrites the result of the previous operation, possibly causing application problems.

The RMS API does not provide any predefined mechanisms for locking transactions.

The record store maintains a date/time stamp indicating the last modification of the record store and a version number. The date/time stamp consists of a long integer representing the time in the format of the System.currentTimeMillis() method. Each time the record store is modified, the date/time stamp is updated. The version number is represented by an integer value. It is incremented for each modifying operation on the record store.

The primary key to records in a record store is an integer value called the record ID. The ID of the first record created is 1. The IDs of subsequent records are incremented by 1.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset