0

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.

2
Contributors
2
Replies
3
Views
7 Years
Discussion Span
Last Post by Hakoo
0

Hey,
Thanks for reply. Actually, you are right. Had problem in stream only. My colleague was not resetting it.

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.