Note that there are some explanatory texts on larger screens.

plurals
  1. PORead and write RMS in j2me
    text
    copied!<p>I am doing a game in J2ME . I want save data level and score in RMS .This is my code This is class RMSData :</p> <pre><code>public class RMSData { private static RecordStore rs = null; static final String REC_STORE = "ReadWriteRMS"; public static void openRecStore(){ try { rs = RecordStore.openRecordStore(REC_STORE, true); } catch (Exception e) {} } public static void closeRecStore(){ try { rs.closeRecordStore(); } catch (Exception e) {} } public static void deleteRecStore(){ if(RecordStore.listRecordStores()!= null){ try { RecordStore.deleteRecordStore(REC_STORE); } catch (Exception e) {} } } public static void writeRecStore(String str){ byte[] rec = str.getBytes(); try { rs.addRecord(rec, 0, rec.length); } catch (Exception e) {} } public static String readRecStore(){ String kq =null; try{ byte[] recData = new byte[5]; int len; if (rs.getNumRecords()==0) return null; for(int i = 1; i &lt;= rs.getNumRecords(); i++){ if(rs.getRecordSize(i) &gt; recData.length){ recData = new byte[rs.getRecordSize(i)]; } len = rs.getRecord(i, recData, 0); if (i==rs.getNumRecords()) kq = new String(recData, 0, len); } }catch (Exception e){} return kq; } } </code></pre> <p>I write level and score to RMS :</p> <pre><code>RMSData.openRecStore(); RMSData.writeRecStore(String.valueOf(LevelPlay)); RMSData.writeRecStore(String.valueOf(Score)); RMSData.closeRecStore(); </code></pre> <p>And then I read it :</p> <pre><code>RMSData.openRecStore(); String st = null; if(RMSData.readRecStore() == null) st = "Level : 0"+"Score : 0"; else st = "Level : "+RMSData.readRecStore()+"Score : "+RMSData.readRecStore(); RMSData.closeRecStore(); </code></pre> <p>But it can't read the data.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload