I use RecordStore to store my data.
I know when we store data in RecordStore, it automatically generates a record id for each record.
But how can I set the record id by myself? Or how can I get the record id?
Because I want to use the recordstore.setRecord(..) method to update my recordstore.
But when I use RecordEnumeration to fetch RecordStore and use method nextRecordId(), it just shows odd or even ids. I mean when I have 8 records, it just prints out only odd or even records like
2 4 6 8
My code:
handleRecord.openRecordStore(handleRecord.getRecordName());
RecordEnumeration re;
try {
int rc = handleRecord.getRecordStore().getNumRecords();
re = hrs.getRcs().enumerateRecords(null, null, true);
while(re.hasNextElement()) {
int rid = re.nextRecordId();
System.out.println(rid);
}
} catch(Exception e) {
System.out.println(e.toString());
}
MIDP API doesn’t have method to set record id by yourself.
See RecordStore API documentation for explanation how this is supposed to work.
The code that iterates the store appears OK:
if you’re getting only odd or even record like 2-4-6… or 1-3-5… printed as a result, first thing to check is whether you somehow removed records that are “missing” – this could be done eg using
RecordStore.getVersionmethod: