java me - how to check first value in rms is null in j2me? -


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 want check whether rms contains first value or not, otherwise enter new value in it??? still little bit confused whether information going stay permanent in mobile or not...

an information permanently stored in rms , discussed regards this. see sample code , try 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 reference,

  1. persistent data in java me
  2. how use rms in j2me

Comments

Popular posts from this blog

Javascript line number mapping -

c# - Is it possible to remove an existing registration from Autofac container builder? -

php - Mysql PK and FK char(36) vs int(10) -