Hi all
I tried executing the following code for maintaining a record store. The issue I am facing is that the first time when I run this code the record store is created and data is inserted in it.
package temp;
import javax.microedition.midlet.*;
import javax.microedition.rms.*;
public class recordstore extends MIDlet {
public recordstore() {
}
public void startApp() throws MIDletStateChangeException {
String s="";
RecordStore rs=null;
System.out.println(s);
try {
rs = RecordStore.openRecordStore("file6",true);
String temp="This is for phone number 5550001";
rs.addRecord(temp.getBytes(), 0,temp.getBytes().length);
System.out.println("record store file1 is opened and the record count is-->"+rs.getNumRecords());
}catch(Exception e){
System.out.println("Error: "+e.getMessage());
}
finally{
//close the record store
try {
rs.closeRecordStore();
System.out.println("record store file6 is closed");
}catch (Exception e){
System.out.println("Error: "+e.getMessage());
}
}
destroyApp(true);
notifyDestroyed();
}
/**
* Pause the MIDlet
*/
public void pauseApp() {
}
/**
* Called by the framework before the application is unloaded
*/
public void destroyApp(boolean unconditional) {
}
}
but the second time when I try using this code with the open record store set to false ( the record store should have been returned) I am getting a record store not found exception.
package temp;
import javax.microedition.midlet.*;
import javax.microedition.rms.*;
public class recordstore extends MIDlet {
public recordstore() {
}
public void startApp() throws MIDletStateChangeException {
String s="";
RecordStore rs=null;
System.out.println(s);
try {
rs = RecordStore.openRecordStore("file6",false);
String temp="This is for phone number 5550001";
rs.addRecord(temp.getBytes(), 0,temp.getBytes().length);
System.out.println("record store file1 is opened and the record count is-->"+rs.getNumRecords());
}catch(Exception e){
System.out.println("Error: "+e.getMessage());
}
finally{
//close the record store
try {
rs.closeRecordStore();
System.out.println("record store file6 is closed");
}catch (Exception e){
System.out.println("Error: "+e.getMessage());
}
}
destroyApp(true);
notifyDestroyed();
}
/**
* Pause the MIDlet
*/
public void pauseApp() {
}
/**
* Called by the framework before the application is unloaded
*/
public void destroyApp(boolean unconditional) {
}
}
Please help me out solve this issue.
Regards
Kartik