j2me RMS不能持久的问题

来源:百度知道 编辑:UC知道 时间:2024/06/02 19:04:44
RMS中我使用RecordStore rs = RecordStore.openRecordStore(“ABCD”, true)建立了一个名字为ABCD的持久化文件。
但是在下一次打开时,比如用RecordStore.openRecordStore(“ABCD”, false)系统就会报错,说找不到文件。
这是为啥?难道是建立的时候有什么问题?

//请参考我的这段代码。

try{
rs=RecordStore.openRecordStore(rmsName,true,RecordStore.AUTHMODE_PRIVATE,true);
}catch(Exception e){}

public void savePlayer(Players player) throws RecordStoreException
{ //存储
ByteArrayOutputStream baos=new ByteArrayOutputStream();
DataOutputStream dos=new DataOutputStream(baos);
numberS=rs.getNumRecords();

try{
player.serialize(dos);
byte[] data=baos.toByteArray();
rs.addRecord(data,0,data.length);
// System.out.println("成功插入信息 "+numberS);
dos.close();
}catch(IOException e){}
catch(RecordStoreException ee){}
}

public Players getPlayer(int recornID) throws Exception
{//获得
byte[] data=rs.getRecord(recornID);