Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
J2ME RMS
1. J2ME –
Record management system
Rohan Chandane
rohan.chandane@indiatimes.com
This notes are created by me, Rohan Chandane as learning material while pursuing MSc (CA) from SICSR. (CC) 2005-07
2. Basics
Record Management System (RMS)
Provides a mechanism
MIDlets can
Persistently store data
Retrieve it later even if device switched off
It stores data in binary format in mobile
device
4. Records and Record Store
Storage Mechanism termed as
Record Store
Record Store consist
Records – Individual units of storage
Record
Is an array of bytes
Stored in binary file
5. Package
Package used
javax.microedition.rms
For Record stored class used
javax.microedition.rms.RecordStore
Provides several methods to manage
records in Record Store
Insert
Update
Delete
6. RecordStore Class
Methods in RecordStore
openRecordStore()
Open Record Store
closeRecordStore()
Close Record Store
deleteRecordStore()
Delete Record Store
enumerateRecords()
Used to obtain enumeration object, which
represents entire set of records in Record Store
7. Continued…
getName()
Used to obtain name of Record Store
getRecord()
Retrieve a record from Record set
getNumRecord()
Obtain a number of records in Record Store
addRecord()
Add record to Record Store
deleteRecord()
Delete record from Record Store
8. Continued…
Interfaces in RMS package
RecordEnumeration
Provide navigation in both direction through
record store
It has following methods defined
nextRecordId() – returns Id of next record
nextRecord() – returns next record
previousRecordId() – returns Id of previous record
previousRecord() – returns previous record
hasNextElement() – true, if there is next record
hasPreviousElement() – true, if there is previous
record
9. Continued…
RecordComparator
Provide comparison between two records in a
record store
RecordFilter
Provide a mechanism to check if a record
matches a specific criterion
RecordListener
Provide an event listener that is notified when
event is added, deleted or modified
10. Managing record stores
Open a RecordStore
RecordStore rs = RecordStore.openRecordStore(quot;MyAppointmentsquot;,true);
Close a RecordStore
Rs.closeRecordStore();
Delete a RecordStore
RecordStore.deleteRecordStore(quot;MyAppointmentsquot;);
11. Continued…
Insert a record
String appt = quot;new recordquot;;
byte bytes[] = appt.getBytes();
rs.addRecord(bytes,0,bytes.length);
Updating records
String newappt = quot;update recordquot;;
Byte data = newappt.getBytes();
Rs.setRecord(1, data, 0, data.length());
12. Continued…
Deleting records
Rs.deleteRecord(1);