Record Management System (RMS) has been used as persistent storage for keeping mobile phones’ users records. It works similarly like desktop file-based database (e.g. dBase or dbf-formatted database). In order to store records, there are no exact SQL-command-like commands that can be used. Instead, an application has to convert records into byte arrays and then store them one-by-one or in sequence. Each record will occupy a row which could have data that are grouped into several columns. Unlike in desktop databases where each data could be stored into its column by just mentioning the name of the destined column (e.g. INSERT INTO table1 (column1, column2) VALUES (value1, value2)), RMS has to know the correct column order or sequence in order to have byte arrays of data stored in the correct column. This is very contrast to desktop databases (e.g. MySQL, Ms SQL Server, Oracle, etc) where data can be stored easily by just invoking SQL commands. However, compared to desktop database, RMS are lighter, more compact in term of size, and can be faster accessed. That’s why it is suitable for small mobile devices which have limited computing and storage resources to use it as persistent storage.
RMS of an application may contain several Record Stores. Record Store can be illustrated as Table in term of common desktop database management system. To create or open a Record Store, RecordStore.openRecordStore() method can be used. In order to create or store a record, one must convert or pack the data into byte arrays using DataOutputStream and ByteArrayOutputStream classes then add the record using the RecordStore.addRecord() method. Conversely, reading records will be done by unpacking the byte arrays using DataInputStream and ByteArrayInputStream classes. In addition, when a Record Store stores a record, it assigns unique record ID to it. Later on, this record ID will be used when the application wants to access that particular record. Ability of accessing particular record might come into handy when one wants to update or delete records. To delete a record, RecordStore.deleteRecord() can be used. For updating a particular record, method of RecordStore.setRecord() can be used. Of course, both of these methods require the record ID as its parameter. Finally, when all Record Store operations are done and it is no longer needed, one can use RecordStore.close to close the Record Store.
No comments:
Post a Comment