J2ME - Record Management System: Rohan Chandane

Download as pdf or txt
Download as pdf or txt
You are on page 1of 12

J2ME –

Record management system

Rohan Chandane
[email protected]

This notes are created by me, Rohan Chandane as learning material while pursuing MSc (CA) from SICSR. (CC) 2005-07
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
Overview of J2ME RMS and
MIDlet interfacing
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
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
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
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
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
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
Managing record stores
 Open a RecordStore
RecordStore rs = RecordStore.openRecordStore("MyAppointments",true);

 Close a RecordStore
Rs.closeRecordStore();

 Delete a RecordStore
RecordStore.deleteRecordStore("MyAppointments");
Continued…
 Insert a record
String appt = "new record";
byte bytes[] = appt.getBytes();
rs.addRecord(bytes,0,bytes.length);

 Updating records
String newappt = "update record";
Byte data = newappt.getBytes();
Rs.setRecord(1, data, 0, data.length());
Continued…
 Deleting records
Rs.deleteRecord(1);

You might also like