import java.util.Vector;
import javax.microedition.rms.RecordStore;
public class Add {
public void addRec(){
try{
RecordStore recordStore = RecordStore.openRecordStore("words", true );
recordStore.addRecord("a".getBytes(), 0, "Imdad".getBytes().length);
recordStore.addRecord("b".getBytes(), 0, "Asmat".getBytes().length);
recordStore.addRecord("c".getBytes(), 0, "Inam".getBytes().length);
recordStore.addRecord("d".getBytes(), 0, "Ikram".getBytes().length);
recordStore.addRecord("e".getBytes(), 0, "Shafqat".getBytes().length);
recordStore.closeRecordStore();
}catch(Exception e){}
}
public void insert(
String str){
try{
RecordStore rs=RecordStore.openRecordStore("words", true);
rs.addRecord(str.getBytes(), 0, str.getBytes().length);
System.out.println("Added user");
}catch(Exception e){}
}
public Vector getRec(){
Vector vt=new Vector();
try{
RecordStore recordst=RecordStore.openRecordStore("words", true);
int u=recordst.getNumRecords();
System.out.print(u);
for(int i=1; i<=recordst.getNumRecords(); i++){
byte br[]=recordst.getRecord(i);
String tr=new String(br);
vt.addElement(tr);
}
}catch(Exception e){}
return vt;
}
}
-------------------------------------------
insert method will be called when user press insert button on a form which has textfield. The value of that text field should store in recordStore. These values should not be deleted when application is closed.