you should first open recordStore and than read it's contents. in getRecordData() method you should first open record store and than use
RecordEnumeration enumeration = recordStore.enumerateRecords(null, null, false);
modify method to this:
public String [] getRecordData()
{
String[] str = null;
int counter = 0;
try
{
recordStore = RecordStore.openRecordStore("NameOfrecordStore", true);
RecordEnumeration enumeration = recordStore.enumerateRecords(null, null, false);
str = new String[recordStore.getNumRecords()];
while(enumeration.hasNextElement()){
try{
str[counter] = (new String(enumeration.nextRecord()));
counter ++;
}catch (Exception e){
e.printStackTrace();
}
}
} catch (Exception e){
e.printStackTrace();
}
return str;
}
do same thing in getRecordData2() add this code
recordStore2 = RecordStore.openRecordStore("NameOfrecordStore2", true);
before
RecordEnumeration enumeration = recordStore2.enumerateRecords(null, null, false);
remember when you use rms first open record store and than use it(read, change, delete,...).
// new answer to question //replace this code with your according code;
//first replace this
addition.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent ae) {
String s =tf.getText();
if(rb.isSelected()){
if(s!=null && s.length() > 0){
try{
byte bytestream[] = s.getBytes() ;
recordStore = RecordStore.openRecordStore("RecordStore1", true);
int i = recordStore.addRecord(bytestream, 0, bytestream.length);
}catch(Exception ex) {
ex.toString();
}
}
}else if (rb2.isSelected()){
if(s!=null && s.length() > 0){
try{
byte bytestream[] = s.getBytes() ;
recordStore2 = RecordStore.openRecordStore("RecordStore2", true);
int i = recordStore2.addRecord(bytestream, 0, bytestream.length);
}catch(Exception ex) { }
}
}
.....
}
});
//second
All.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent ae) {
ff.removeAll();
try{
com.sun.lwuit.Label l = new com.sun.lwuit.Label("First Team Goals") ;
ff.addComponent(l);
String [] record= getRecordData();
List mylist = new List(new DefaultListModel(record));
ff.addComponent(mylist);
com.sun.lwuit.Label ll = new com.sun.lwuit.Label("Second Team Goals") ;
ff.addComponent(ll);
String [] record2= getRecordData2();
List mylist2 =new List(new DefaultListModel(record2));
ff.addComponent(mylist2);
}catch(java.lang.IllegalArgumentException e){}
ff.show();
}
});
its work well, its perfect!!.