Question

RecordStore rs = RecordStore.openRecordStore("StoryDataBase1",true);
String data_to_write_in_file = Slug.getString()+"^"+title.getString()+"^"+Body.getString()+"^"+com.editorial.Main.MainImagePath+"^"+com.editorial.Main.MainVideoPath+"^"+com.editorial.Main.MainVoicePath+"$";

byte b[] = rs.getRecord(1);
String str = new String(b,0,b.length);
if(str.equals("")) {
byte bytes[] = data_to_write_in_file.getBytes();    
rs.addRecord(bytes,0,bytes.length);
}
else
{
str=str+data_to_write_in_file;
byte[] data = str.getBytes();
rs.setRecord(1, data, 0, data.length);
}    
rs.closeRecordStore();

in this i want to check whether rms contains first value or not, otherwise it will enter new value in it??? But i am still little bit confused that whether information going to stay permanent in mobile or not...

Était-ce utile?

La solution

An information permanently stored in RMS and We are already discussed regards this. See this sample code and try like this,

    byte[] recData = null;
    int len;
    RecordStore rs = RecordStore.openRecordStore("StoryDataBase1", true);

    if (rs.getNumRecords() > 0) {
    recData = new byte[rs.getRecordSize(1)];
    len = rs.getRecord(1, recData, 0);
    String value = new String(recData, 0, len);
    if(value == null) {
    ....
    } else {
    ...
     }
    }

Updates

See these links for your reference,

  1. Persistent Data in Java ME
  2. How to use RMS in j2me
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top