Search code examples
arrayliststoragecodenameone

storage automatically get cleared in codename one


Hi I am writing an arraylist in storage using

private void addItemToRecentListStorage1(Hashtable h){ Storage s1 = Storage.getInstance(); ArrayList<Hashtable> a = (ArrayList<Hashtable>)s1.readObject("RecentItems"); ... ... a.add(0,h);//adding on top s1.writeObject("RecentItems", a); }

If I inspect s1 immediately after adding 1st element, it shows me appropriately in storage hierarchy.

1st entry has 4 elements

But at a time of adding 2nd element(HashTable) it clear the 1st stored hashtable values, though it shows as a blank element.

before adding 2nd entry

Means, I am getting 1 element(HashTable) in arraylist by readObject() but that hashtable's all 4 elements are wiped out. This was working earlier but now its wiping out HashTable data from arraylist.

So eachtime I am getting number of element incremented by 1 when I add element. But all previous hashtables' values are cleared.

Same thing is happening in emulator as well as device.


Solution

  • Check out if you have an exception in the console that might have been triggered by serialization failing for some of the objects within the array.