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