Record Management System (II)
24 April 2008Do read the first part of this post. This post is code specific. I will present some sode snippets to make things obvious.
Opening the Record Sote is very easy.
RecordStore rs = RecordStore.openRecordStore("MyContact",true);
To add a record, javax.microedition.rms.RecordStore provides the followig method:
public int addRecord(byte[] data, int offset, int numBytes)
Example follows below:
String appt = "new record"; byte bytes[] = appt.getBytes(); rs.addRecord(bytes,0,bytes.length);
Let me show you how to delete a record from a Record Store:
To update a record, you first have to get that record using the following method:
public int getRecord(int recordId, byte[] buffer, int offset)
It will return the data stored in the given record in form of byte array
Now use the setRecord method to update the record:
public void setRecord(int recordId, byte[] newData, int offset, int numBytes)
Example follows below:
tring newappt = "update record"; Byte data = newappt.getBytes(); Rs.setRecord(1, data, 0, data.length());
Related Posts:
- Record Management System (I)
- RecordStore with examples - II
- Record Management System (III)
- RecordStore with examples - I
- RecordStore with examples - III
- in.use file
- ANT’s best practices - IV
- SVN (Trunk/Branch/Tag) - II
- Java performance Issues (III) - Garbage collection
- Deploying MIDlets onto Mobile Devices (III)
Top Of Page | Trackback
If you found this page useful, consider linking to it. Simply copy and paste the code below into your web site.
It will look like this: Record Management System (II)