Skip to main content

rs.deleteRecord(int) deletes more than one record

2 replies [Last post]
Anonymous

I've got a problem when deleting a record in the RecordStore using the Nokia N70 using the following code:

RecordStore db=null;
db = RecordStore.openRecordStore("store", true);
db.deleteRecord(index);
db.closeRecordStore();
db=null;

This code seems to delete more than one record for some reason? I've checked the stack traces and have tried the code on other phones and emulators - it only seems to do it on the N70 from the phones I've tested. Any ideas?

The code that reads stored records is:

db = RecordStore.openRecordStore("store", true);
int num = db.getNumRecords();

int h=db.getNextRecordID();

for(int i=h-1; i>-1; i--){

try{
byte [] b = db.getRecord(i);
}catch(Exception e){
//deleted
}
}
...........

===========================================================================
To unsubscribe, send email to listserv@java.sun.com and include in the body
of the message "signoff KVM-INTEREST". For general help, send email to
listserv@java.sun.com and include in the body of the message "help".
[att1.html]

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
Daniel Rocha

Hi list,

Just to follow up on this, the use of RecordEnumeration solved the
problem, so N70's RMS implementation works OK.

Daniel

________________________________

From: A mailing list for KVM discussion
[mailto:KVM-INTEREST@JAVA.SUN.COM] On Behalf Of ext Daniel Rocha
Sent: Thursday, February 22, 2007 8:34 PM
To: KVM-INTEREST@JAVA.SUN.COM
Subject: Re: rs.deleteRecord(int) deletes more than one record

Hi Chris,

Why are you using getNextRecordID() to read the data? This method exists
basically for implementing pseudo-relacional record storing, as
described in the JavaDocs.

The code for reading data assumes that the record id's are sequential
and all of them are there. This may or may not be valid for different
reasons, e.g. call to getNextRecordID() not followed by addRecord.

Standard code for reading all the records is here:

RecordStore rs = RecordStore.openRecordStore("store", true);
RecordEnumeration enumeration = rs.enumerateRecords(null,null,true);

while(enumeration.hasNextElement()) {
int recordID = enumeration.nextRecordId();
byte[] myBytes = rs.getRecord(recordID);
} // while

Also, I am not aware of any problems with N70's RMS implementation, as
it's the same as many other S60 devices and those do not present
problems either.

[]s
Daniel Rocha
Forum Nokia
________________________________

From: A mailing list for KVM discussion
[mailto:KVM-INTEREST@JAVA.SUN.COM] On Behalf Of ext Chris B
Sent: Monday, February 19, 2007 11:13 AM
To: KVM-INTEREST@JAVA.SUN.COM
Subject: rs.deleteRecord(int) deletes more than one record

I've got a problem when deleting a record in the RecordStore using the
Nokia N70 using the following code:

RecordStore db=null;
db = RecordStore.openRecordStore("store", true);
db.deleteRecord(index);
db.closeRecordStore();
db=null;

This code seems to delete more than one record for some reason? I've
checked the stack traces and have tried the code on other phones and
emulators - it only seems to do it on the N70 from the phones I've
tested. Any ideas?

The code that reads stored records is:

db = RecordStore.openRecordStore("store", true);
int num = db.getNumRecords();

int h=db.getNextRecordID();

for(int i=h-1; i>-1; i--){

try{
byte [] b = db.getRecord(i);
}catch(Exception e){
//deleted
}
}
............

========================================================================
=== To unsubscribe, send email to listserv@java.sun.com and include in
the body of the message "signoff KVM-INTEREST". For general help, send
email to listserv@java.sun.com and include in the body of the message
"help".
========================================================================
=== To unsubscribe, send email to listserv@java.sun.com and include in
the body of the message "signoff KVM-INTEREST". For general help, send
email to listserv@java.sun.com and include in the body of the message
"help".

===========================================================================
To unsubscribe, send email to listserv@java.sun.com and include in the body
of the message "signoff KVM-INTEREST". For general help, send email to
listserv@java.sun.com and include in the body of the message "help".
[att1.html]

Daniel Rocha

Hi Chris,

Why are you using getNextRecordID() to read the data? This method exists
basically for implementing pseudo-relacional record storing, as
described in the JavaDocs.

The code for reading data assumes that the record id's are sequential
and all of them are there. This may or may not be valid for different
reasons, e.g. call to getNextRecordID() not followed by addRecord.

Standard code for reading all the records is here:

RecordStore rs = RecordStore.openRecordStore("store", true);
RecordEnumeration enumeration = rs.enumerateRecords(null,null,true);

while(enumeration.hasNextElement()) {
int recordID = enumeration.nextRecordId();
byte[] myBytes = rs.getRecord(recordID);
} // while

Also, I am not aware of any problems with N70's RMS implementation, as
it's the same as many other S60 devices and those do not present
problems either.

[]s
Daniel Rocha
Forum Nokia
________________________________

From: A mailing list for KVM discussion
[mailto:KVM-INTEREST@JAVA.SUN.COM] On Behalf Of ext Chris B
Sent: Monday, February 19, 2007 11:13 AM
To: KVM-INTEREST@JAVA.SUN.COM
Subject: rs.deleteRecord(int) deletes more than one record

I've got a problem when deleting a record in the RecordStore using the
Nokia N70 using the following code:

RecordStore db=null;
db = RecordStore.openRecordStore("store", true);
db.deleteRecord(index);
db.closeRecordStore();
db=null;

This code seems to delete more than one record for some reason? I've
checked the stack traces and have tried the code on other phones and
emulators - it only seems to do it on the N70 from the phones I've
tested. Any ideas?

The code that reads stored records is:

db = RecordStore.openRecordStore("store", true);
int num = db.getNumRecords();

int h=db.getNextRecordID();

for(int i=h-1; i>-1; i--){

try{
byte [] b = db.getRecord(i);
}catch(Exception e){
//deleted
}
}
............

========================================================================
=== To unsubscribe, send email to listserv@java.sun.com and include in
the body of the message "signoff KVM-INTEREST". For general help, send
email to listserv@java.sun.com and include in the body of the message
"help".

===========================================================================
To unsubscribe, send email to listserv@java.sun.com and include in the body
of the message "signoff KVM-INTEREST". For general help, send email to
listserv@java.sun.com and include in the body of the message "help".
[att1.html]