2
1.Problem上模拟器:
我在发起第一次我的MIDlet程序是存储一些数据,然后我重新启动它在第二次是读取存储的数据。前两种情况没有任何例外,它运行良好。与RMS的问题存储持久性数据
但是我重新启动它第二次以同样的方式然后它给出异常:“未捕获的异常java/lang/NumberFormatException:”它只处理字符和总数据少于64 kb。
2.关于真实设备的问题:
RMS根本不起作用。我不知道是否需要给予手机许可(诺基亚n95)。
谢谢。
在应用程序,它只是根据所选国家存储慈善公司成rms。所以如果一个国家已经被选中,它必须跳过国家列表,然后在每次重启时显示公司列表。 在下面的代码中,rms_Check()方法是检查数据以打开国家或公司列表框架。
public class X {
private static RecordStore rs =null;
private static Vector rms_Vector = new Vector();
static final String REC_STORE ="db_1";
public X() {
}
public void openRecStore(){
try {
rs = RecordStore.openRecordStore(REC_STORE, true);
System.out.println("open record store");
} catch (Exception e)
{
db(e.toString()+" in openRecStore");
}
}
public void closeRecStore(){
try {
rs.closeRecordStore();
} catch (Exception e) {
db(e.toString()+" in closeRecStore");
}
}
public void deleteRecStore()
{
if (RecordStore.listRecordStores()!=null){
try {
RecordStore.deleteRecordStore(REC_STORE);
} catch (Exception e) {
db(e.toString()+" in deleteRecStore");
}
}
}
public void writeRecord(String str) throws UnsupportedEncodingException
{
byte[] rec = str.getBytes("UTF-8");
try {
rs.addRecord(rec, 0, rec.length);
System.out.println("write record store");
} catch (Exception e) {
db(e.toString()+" in writeRecord");
}
}
public void readRecord()
{
try {
// Intentionally it is too small to test code
byte[] m_enc = new byte[5];
byte[] recData = new String(m_enc).getBytes("UTF-8");
int len;
for(int i =1; i<= rs.getNumRecords(); i++){
if(rs.getRecordSize(i)> recData.length)
recData = new byte[rs.getRecordSize(i)];
len = rs.getRecord(i, recData, 0);
System.out.println("Record #"+i+":"+new String(recData, 0, len));
System.out.println("------------------------");
rms_Vector.addElement(new String(recData, 0, len));
}
} catch (Exception e) {
db(e.toString() +" in readStore");
}
}
private void db(String str)
{
System.out.println("Msg:"+str);
}
public Vector rms_Array(){
return this.rms_Vector;
}
public boolean rms_Check(){
if(this.rms_Vector.size()>0){
System.out.print("rms_check: true");
// if true it will display company list every time
return true;
}else{
System.out.print("rms_check: false");
//if false it will display country list then company list
return false;
}
}
}
你能分享有问题的代码吗?最好在[SSCCE](http://www.sscce.org/)表格中。至于权限,常规RMS操作不太可能需要权限 – gnat 2012-01-05 20:36:04
请发布代码,以便我们了解到底是什么问题? – 2012-01-06 06:03:49
我分享了代码的RMS部分并编辑了我的问题,我希望现在可以更容易理解。谢谢。 – 2012-01-06 10:41:52