Hello all,
I have developed one application which import all databases into recordstore. This executes successfully, but the problem comes when I try to Filter my records.
here the code is :
public void itemStateChanged(Item item) {
if (item == choiceGroup_ProductCompany) {
RecordFilter filter = new RecordFilter() {
public boolean matches(byte[] candidate) {
ByteArrayInputStream bis = new ByteArrayInputStream(candidate);
DataInputStream dis = new DataInputStream(bis);
String comp;
int res = 0;
try {
dis.readInt();
dis.readUTF();
comp=dis.readUTF();
String s = choiceGroup_ProductCompany.getString(choiceGroup_ProductCompany.getSelectedIndex());
res = (s.toLowerCase()).compareTo(comp.toLowerCase());
System.out.println("Pro_Company:" + s.toLowerCase() + "\t" + "Database:" + comp.toLowerCase());
} catch (Exception e) {
e.printStackTrace();
}
if (res == 0) {
return true;
}
return false;
}
};
try {
choiceGroup_ProductName.deleteAll();
RecordStore rms = RecordStore.openRecordStore("Product", true);
RecordEnumeration renum = rms.enumerateRecords(filter, null, false);
byte[] byt = new byte[2000];
ByteArrayInputStream bis = new ByteArrayInputStream(byt);
DataInputStream dis = new DataInputStream(bis);
while (renum.hasNextElement()) {
rms.getRecord(renum.nextRecordId(), byt, 0);
dis.readInt();
choiceGroup_ProductName.append(dis.readUTF(), null);
dis.readUTF();
dis.reset();
rms.closeRecordStore();
dis.close();
bis.close();
}
} catch (Exception e) {
e.printStackTrace();
}
}
}
and Output is
Pro_Company:dell Database:sony
Pro_Company:dell Database:sony
Pro_Company:dell Database:sony
Pro_Company:dell Database:sony
Pro_Company:dell Database:sony
Pro_Company:dell Database:sony
Pro_Company:dell Database:sony
Here Pro_company is Choicegroup and Database is RecordStore. Here I am expecting Database should keep change. But its not Happening.
Thanking You,
Hakoo Desai.