I want to list all records in the record store. I've declared a list:
Private List tlist = new List("Select One", List.IMPLICIT);
Also enumerated the records:
Form mainf;
Command exit = new Command("Exit", Command.EXIT, 0);
RecordEnumeration re = null;
int numrecords = 0;
try {
re = contactList.enumerateRecords(null, null, false);
numrecords = re.numRecords();
} catch (RecordStoreException rse ) { numrecords = 0;}
Now I just need to know how to list all the records in a list.
Add the Record
into Vector
and use the loop for append the Vector
values into List
. See below sample code,
RecordStore s = RecordStore.openRecordStore(recordStoreName, true);
RecordEnumeration e = s.enumerateRecords(null, null, false);
Vector vector = new Vector();
while(e.hasNextElement()) {
vector.addElement(new String(e.nextRecord()));
}
List l = new List(null, CENTER);
for (int i = 0; i < vector.size(); i++) {
l.append(vector.elementAt(i).toString(), null);
}