数据存储:RMS与持久存储的使用指南
1. RMS记录存储操作
在使用记录存储(RecordStore)时,有一些关键的操作和注意事项。首先,枚举器中有 nextRecord 和 nextRecordId 方法,但不能同时使用它们。因为每次调用这两个方法中的任何一个,枚举器都会前进到下一条记录。所以,为了加载数据,应该只调用其中一个方法。
在之前的代码中,每次应用程序关闭时都会删除整个记录存储。不过,RMS也提供了 deleteRecord 方法来删除单个记录,该方法只需要一个记录ID作为参数。
下面是删除记录存储中所有记录的具体操作步骤:
1. 注释掉 SaveEntriesRMS 方法中之前的实现代码:
// //Delete the existing recordstore if there is one.
// try
// {
// RecordStore.deleteRecordStore("JournalEntries");
// }
// catch (RecordStoreException e1)
// {
// // Do nothing. It's entirely possible that the recordstore
// //doesn't exist
// // yet and will throw an exception. Just silently ignore it.
// }
</
超级会员免费看
订阅专栏 解锁全文
15

被折叠的 条评论
为什么被折叠?



