(名前、数量、所有者、ステータス) を持つアイテムのレコード ストアがあります。
ユーザーがイベントをトリガーしたときに、RecordStore 内のすべてのアイテムのステータスを「購入済み」に設定したい
re = shoppingListStore.enumerateRecords(null, null, false);
while (re.hasNextElement())
{
// read current values of item
byte [] itemRecord = re.nextRecord();
// deserialise byte array
newItemObject.fromByteArray(itemRecord);
// set item status to purchased
newItemObject.setItemStatus("Purchased");
// create new bytearray and call newitemobject . tobytearray
// method to return a byte array of the objects
// (using UTF8 encoded strings~)
byte[] itemData = newItemObject.toByteArray();
// add new byte array to shoppinglist store
shoppingListStore.setRecord(re.nextRecordId(), itemData, 0, itemData.length);
}
ただし、次のレコードを上書きしています (nextRecordId を使用)。私は使用してみましnextRecordId - 1
たが、明らかにこれは最初のものの範囲外です
あなたが助けてくれることを願っていますか?