Skip to Main Content
Wireless Java
book

Wireless Java

by Qusay H. Mahmoud
January 2002
Intermediate to advanced content levelIntermediate to advanced
264 pages
8h 3m
English
O'Reilly Media, Inc.
Content preview from Wireless Java

Programming with the RMS

Database programming with the RMS is relatively straightforward. A record store consists of a collection of records that is uniquely identified by its record ID, which is an integer value. The record ID is the primary key for the records. The first record has an ID of 1, and each additional record is assigned an ID that is the previous value plus 1. The record ID is stored as an integer value, which gives the theoretical limit of 2,147,483,647 records.[10]

Opening, Closing, and Deleting a Record Store

To open a record store, you need to be familiar with the static openRecordStore( ) method of the RecordStore class:

public static RecordStore openRecordStore(String recordStoreName, 
    Boolean createIfNecessary) throws RecordStoreException, 
    RecordStoreFullException, RecordStoreNotFoundException

Here is an example of using this method:

RecordStore db = null;

try {
    db = RecordStore.openRecordStore("myDBfile", true);
} catch (RecordStoreNotFoundException rsnfe) {
    // Handle exception
} catch (RecordStoreFullException fsfe) {
    // Handle exception
} catch (RecordStoreException rse) {
    // Handle exception
}

Assuming that everything works right, this line of code creates a new database file named myDBfile. The second parameter, a boolean which is set to true, says that if the record store does not exist, then you should create it.

Tip

If the openRecordStore( ) method is called by a MIDlet when the record store is already open by another MIDlet in the same MIDlet suite, the ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Wireless J2ME™ Platform Programming

Wireless J2ME™ Platform Programming

Vartan Piroumian
Java Power Tools

Java Power Tools

John Ferguson Smart

Publisher Resources

ISBN: 0596002432Supplemental ContentCatalog PageErrata