MIDP record storage
Create an MIDP record store
1.
Import the
javax.microedition.rms.RecordStore
class.
2.
Invoke
openRecordStore()
, and specify true to indicate that the method should create the record store if the record
store does not exist.
RecordStore store = RecordStore.openRecordStore("Contacts", true);
Add a record to a record store
1.
Import the
javax.microedition.rms.RecordStore
class.
2.
Invoke
addRecord()
.
int id = store.addRecord(_data.getBytes(), 0, _data.length());
Retrieve a record from a record store
1.
Import the following classes:
•
javax.microedition.rms.RecordStore
•
java.lang.String
2.
Invoke
getRecord(int, byte[], int)
. Pass the following parameters:
• a record ID
• a byte array
• an offset
byte[] data = new byte[store.getRecordSize(id)];
store.getRecord(id, data, 0);
String dataString = new String(data);
Retrieve all records from a record store
1.
Import the
javax.microedition.rms.RecordStore
class.
2.
Import the following interfaces:
•
javax.microedition.rms.RecordEnumeration
•
javax.microedition.rms.RecordFilter
•
javax.microedition.rms.RecordComparator
3.
Invoke
openRecordStore()
.
Development Guide
MIDP record storage
48