Record Management System (II)

24 April 2008

Do 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());

del.icio.us:Record Management System (II)  digg:Record Management System (II)  spurl:Record Management System (II)  wists:Record Management System (II)  simpy:Record Management System (II)  newsvine:Record Management System (II)  blinklist:Record Management System (II)  furl:Record Management System (II)  reddit:Record Management System (II)  fark:Record Management System (II)  blogmarks:Record Management System (II)  Y!:Record Management System (II)  smarking:Record Management System (II)  magnolia:Record Management System (II)  segnalo:Record Management System (II)  gifttagging:Record Management System (II)

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)

Leave a Reply