2. Contents
➢Record Storage
➢Record Management System (RMS)
➢Record Store
Record Store Scope
➢Setting Up a Record Store
Creating, Opening, Closing, and Removing a Record Store
Writing and Reading Records
Writing and Reading String based records
Writing and Reading Mixed Data Types
➢References
3. Records
• An individual data item.
• It does not have any data type.
• It is represented by an array of bytes
• A record can contain a string, number, array, image,etc
4. Record Storage
● Most Operating environments contain a file system to
store information in non-volatile resources.
Eg: CD-ROM and disk drive
●But not all small computing devices have a file system and
therefore we are unable to store information in the manner
that we are familiar with.
●To solve this problem we have the Record Management
System, that is used to store and maintain persistence in a
small computing devices.
5. Record Management System (RMS)
●RMS is a combination of file system and database
management system
● It enables storage of data in columns and rows
● RMS performs the functionality of DBMS
●It uses the RMS application programming interface
and the enumeration application programming
interface to interact with data.
●These interfaces are used to sort, search, and
manipulate information stored in persistence.
6. Record Store
● A record store is a collection of records organized as
rows (records) and columns (fields)
● Here, the columns contain like data and rows contain
related data.
● A unique integer known as the Record Id is assigned
to each record.
● A Record Id is the primary key of the record store.
● A record store remains in nonvolatile memory even
after the small computing device is powered down.
7. While naming the records, consider the following,
1. The name of a record store must be a minimum
of one character and not more than 32 characters
2. Characters are Unicode and case sensitive.
8. Record Store Scope
●Record stores can be shared among MIDlets that are within the same MIDlet
suite.
●Let MIDlet A contain information about customers from a sales
representative and MIDlet B display customer information collected by MIDlet
A. Here, MIDlet B is unable to access customer information as MIDlet A and
MIDlet B are in different MIDlet suites.
●However, MIDlet B would have been able to access customer information if
both MIDlet A and MIDlet B were in the same MIDlet suite.
9. Setting Up a Record Store
➢Creating, Opening, Closing, and Removing a Record Store
openRecordStore() method
• This method is called to create a new record store and to open an
existing record store.
• • This method requires two parameters:
a) a string containing the name of the record store.
b) a boolean value indicating whether the record store should
be created if the record store doesn’t exist.
True value => It causes the record store to be created if the record store isn’t
in the MIDlet suite and also opens the record store.
False value=> It does not create the record store if the record store isn’t
located
10. listRecordStores() method
• This method returns a null value if no record stores
exist on the device
closeRecordStore() method
• This method is used to close a record store.
• It does not have any parameters.
11. ●Being the nonvolatile memory ,the record store has to be
managed efficiently.
●This is done by removing all record stores that are no
longer being used by MIDlets.
deleteRecordStore() method
• This method is used to delete a record store.
• It consist of one parameter, which is a string
containing the name of the record store that is to be
removed from the device .
12.
13. ➢Writing and Reading Records
● When a MIDlet opens a record store, it can write records to the
record store and read information already stored there.
●This can be done using two techniques.
1.The first technique is used to write and read a string of data
and is used primarily whenever you have one data column in the
record store such as a list of abbreviations of states.
2.The other technique is used to write and read multiple
columns of data of different types such as string, integer, and
boolean.
14. addRecord() method
• This method is used to write a record to the record store.
• It requires three parameters
a) The first is a byte array containing the byte value of
the string being written to the record store.
b) The second is an integer representing the index of
the first byte of the byte array that is to be written to the
record store. It will be usually zero.
c) The third is the total number of bytes that is to be
written to the record store.it will be the length of the byte
array.
15. Writing a string to a record store
●First we have to create an instance of a string and
assign text to the instance.
●Then the string must be converted to a byte array by
calling the getBytes() method.
getBytes() method
• It is used to convert a string to a byte array.
• This method returns a byte array
16. Reading from a record
●Information is read from a record store one record at a time
and stored in a byte array.
●The byte array is then converted to a string, which is then
displayed on the screen or processed further based on the
needs of the application.
●For MIDlet to know the number of records in a record store,
we use getNumRecords() method.
17. getNumRecords() method
• It is a method of the Record Store class
• This method returns an integer that represents the total number of
records in the record store
getRecord() method
• This method returns bytes from the RecordStore, which are stored in a
byte array that we create.
• It requires three parameters.
a) The first parameter is the record ID
b) The second parameter is the byte array that you create for storing the
record.
c) The third parameter is an integer representing the position in the record
from which to begin copying into the byte array .