I am using rms concept in my j2me application.
Frst records added to rms successfully, then read records also fine but when I am going to add another one record at a same time, that will not be added in my list, it was added to rms successfully but not refreshed that time.
If I go to exit the application once then run the application that records reads well, all the records display. How to refresh the list and get all the records?
This is my source for add records:
public void AddCustomer(String str) throws RecordStoreNotOpenException
{
byte[] rec=str.getBytes();
try
{
rs19 = RecordStore.openRecordStore(ADDREMOVE_CUSTOMER, true);
rs19.addRecord(rec, 0, rec.length);
System.out.println("REcord added successfully");
v.addElement(str);
}
catch (Exception e)
{
}
}
This is source for read records:
public ChoiceGroup getChoiceGroup10() {
if (choiceGroup10 == null) {
choiceGroup10 = new ChoiceGroup("Select Customer", Choice.POPUP);
choiceGroup10.append("none", null);
try
{
rs19.openRecordStore(ADDREMOVE_CUSTOMER, true);
String value="";
String comma=",";
Vector v1=new Vector();
StringBuffer enumList=new StringBuffer();
recEnum = rs19.enumerateRecords( null, null, false );
while( recEnum.hasNextElement() )
{
byte[] data = recEnum.nextRecord();
enumList.append(new String(data));
enumList.append(",");
}
records=new String(enumList);
int index=records.indexOf(comma);
while(index>=0)
{
v1.addElement(records.substring(0,index));
records = records.substring(index+comma.length());
index = records.indexOf(comma);
}
v1.addElement( records );
if( v1.size()>0 )
{
for(int i=0; i<v1.size(); i++)
{
value= (String)v1.elementAt(i);
choiceGroup10.append(value, null);
}
}
}
catch(InvalidRecordIDException ie)
{
ie.printStackTrace();
}
catch(RecordStoreException re)
{
re.printStackTrace();
}
catch(NullPointerException ne)
{
System.out.println(ne);
}
finally
{
try {
rs19.closeRecordStore();
} catch (RecordStoreException ex) {
ex.printStackTrace();
}
}
}
return choiceGroup10;
}