我想每次使用此代码时从RecordStore中删除一条记录,这意味着第二次用户看到记录时,他不应该看到已删除的记录,但这种情况不会发生。从RecordStore中删除记录
经过测试我的代码创建recordStore上的相同记录。 !
这些是我输入的记录。
_1_Elhadi_ _Sun 1月26日01:00:00 GMT + 03:00 2014
_A_John_ 太阳1月26日01:00:00 GMT + 03:00 2014
_3_Smith_ 太阳1月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();
}
}
@AliPour您能否提供吗? – JavaFan