| 方法/属性 | 描述 |
|---|---|
| openRecordStore | 打开一个记录存储,以便读出或写入数据 |
| getNumRecords | 获得纪录存储中记录的数目 |
| int getRecordSize(recordID) | 获得一条记录的数据大小 |
| byte[] getRecord(recordID) int getRecord(recordID, byte[], offset) |
从一个单独的纪录中获得数据 |
| addRecord | 向一个记录存储添加一条记录的数据 |
| deleteRecord | 删除一条的纪录 |
| static deleteRecordStore(recordStoreName) | 删除整个记录存储 |
| closeRecordStore() | 关闭一个记录存储 |
| static RecordStore openRecordStore(recordStoreName, createIfNecessary) |
| 参数 | 描述 |
|---|---|
| recordStoreName | 记录存储名 |
| createIfNecessary | 是否自动建立(不存在时) |
| int addRecord(byte[] data, int offset, int numBytes) |
| 参数 | 描述 |
|---|---|
| data | 需要存储的数据 |
| offset | 开始偏移 |
| numBytes | 总字节数 |
| 返回值 | 记录ID |
| byte[] getRecord(recordID) |
| int getRecord(int recordID, byte[] buffer,int offset) |
| 参数 | 描述 |
|---|---|
| recordID | 记录 ID |
| buffer | 缓存 |
| offset | 缓存偏移 |
| 返回值 | byte[] 字节数组 int 存储的字节数 |
| RecordStore rs; try { rs = RecordStore.openRecordStore("save1", true); rs.addRecord(String.valueOf(c.flag[0][0]).getBytes(), 0, String.valueOf(c.flag[0][0]).getBytes().length); rs.closeRecordStore(); } catch(Exception e) { } |
| RecordStore rs; try { RecordEnumeration re; byte[] a; rs = RecordStore.openRecordStore("save1", true); re = rs.enumerateRecords(null,null,false); while(re.hasNextElement()) { id = re.nextRecordId(); a = new byte[rs.getRecordSize(id)]; a = rs.getRecord(id); } rs.closeRecordStore(); } catch(Exception e) { } |