0

I want to delete one record from a RecordStore each time I use this code ,that means the second time when user see the records he shouldn't see the deleted record, but that doesn't happen.

After testing my code same records on the recordStore founded. !!!

These are records I entered.

_1_Elhadi__Sun Jan 26 01:00:00 GMT+03:00 2014

_A_John_Sun Jan 26 01:00:00 GMT+03:00 2014

_3_Smith_Sun Jan 26 01:00:00 GMT+03:00 2014

public void deleteRecStore(String recID) {

try
 {
 recordStore.openRecordStore("recordStore", true)   ;
 }
 catch(Exception ex)
 {
 ex.printStackTrace();
 }
 try
 {

 RecordEnumeration e = recordStore.enumerateRecords(null,null,false);

 int found = -1;

 while (e.hasNextElement()) 
 {

 int id = e.nextRecordId();

 String next = new String(e.toString());

 int fee = next.indexOf("_", 1);

 **// These statements don't print anything** 

System.out.print("next.indexOf" +next.indexOf("_", 1));


System.out.println( "next.substring(1, fee)"+"\t" +next.substring(fee, 1));

System.out.println("recID"+"\t"+recID);

if (next.substring(1, fee).equals(recID))

{

found = id ;

}
  }
if (found == -1)

{

System.out.println("not found!");
}
else
{
recordStore.deleteRecord(found);
}
   }
 catch(Exception ex)
 {
 ex.printStackTrace();
 }
     }            
PHPFan
  • 756
  • 3
  • 12
  • 46

1 Answers1

0

I think the error is this line:

String next = new String(e.toString());

Looks like you're converting your RecordEnumeration object into a String object, and trying to find the record id in that string. That won't get you far.

Try replacing that line with this line and see if it helps:

String next = new String(recordStore.getRecord(id));
mr_lou
  • 1,910
  • 2
  • 14
  • 26