Skip to main content

RMS help

4 replies [Last post]
Joined: 2009-05-16

I'm developing RMS, and able to add & delete records from J2ME RMS.
I'm able to delete record using

store.deleteRecord(int recId)

but, the issue is I can't delete the record using same recId.
In my Application I'm allowing user to store his favorites.
if user deletes the 3rd record the next one(i.e.,fourth record) should come to 3rd position.
Is there any way to solve this issue, atleast any help link.
let the deleted one go out of picture.
bookmarks are shown to user as List(UI component).
when a user deletes 3rd item List, the RMS will also be deleted.
my question here is, if the user delets the 3rd item again it shall not result in error.
so, is there any way to remove deleted space like we remove in linkLists/Arrays in C/C++.

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
Joined: 2009-05-16

got solution from Nokia forum
Once you delete the record from a ID,then that id can not be used any more,neither you can add the record on the same nor you can do any other operation.

The work around is that, as soon as you delete the record from the specific id,then copy that total content of the RMS in vector,delete the complete RMS,and then create the new RMS with the data in the vector,

Please check that whether these lines can help you,

Joined: 2006-10-18

Ooops my bad. Somehow I ignored second part of question because of that underlining in middle.
Yes, if data are removed ID of the record cannot be reused again. Only possible way would be to read all data out, clean record store and store them again, as that post on Nokia forum mention. Also this is clearly stated in API too.
Question is if this is worth the effort to do this read-clear-store process in your application?

Joined: 2009-05-16

thnx peter_budo.

my App is client-oriented. so I've to sync with client requests.

thnx anyway,

Joined: 2006-10-18

This should be fairly easy. I guess you are not reading actual record ID but rather some relative number either from array or vector position, or position from display list.

rsm = new RecordStoreManager();
RecordStore rs = rsm.openRSM();
try {
RecordEnumeration re = rs.enumerateRecords(null, null, false);
while (re.hasNextElement()) {
int i = re.nextRecordId();
byte[] record = rs.getRecord(i);
} [/code]
I do use this fancy RecordStoreManager class to handle opening and closing, so nothing special. What is important, RecordEnumeration help you iterate through your records and help you read unique record ID. Then you will use ID to read data associate with this record. Then if you store record ID as instance variable of a record object your life will be easier