Hi there,
I have a record store of items which have (name, quantity, owner, status)
Now when the user triggers an event i want to set the status of all items in my recordstore with "purchased"
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 object (using UTF8 encoded strings~)
byte[] itemData = newItemObject.toByteArray();
// add new byte array to shoppinglist store
shoppingListStore.setRecord(re.nextRecordId(), itemData, 0, itemData.length);
}
However I am overwriting the next record (using the nextRecordId), i've tried using nextRecordId - 1 but obviously this is out of bounds on the first one
Hope you can help,
Many thanks,
andy