I have this code which works well:
static {
myStore = PersistentStore.getPersistentObject(MY_LONG_KEY);
myList = (Vector) myStore.getContents();
if (_storedStations == null) {
myList = new Vector(4);
// prepopulate with fake data
myList.addElement(new MyItem("Eins"));
myList.addElement(new MyItem("Zwei"));
myList.addElement(new MyItem("Drei"));
myList.addElement(new MyItem("Vier"));
myStore.setContents(myList);
}
}
class MyItem implements Persistable {
.....
}
probably because the PersistentObject doc says:
Implicit persistance
Notice that some classes are implicitly persistable: Boolean, Byte, Character, Integer, Long, Object, Short, String, Vector, Hashtable.
Also note that, when you persist an object, any persistable object it refers to will also get persisted.
But what about other data structures? For example - instead of the Vector used above - I'd like to have a Hashtable with keys: Strings and values: MyItems. How can I make it Persistable and ensure that MyItem contents is really stored, no matter how complex that object is?
And why is IntHashtable listed as Persistable, but Hashtable is not?
Thank you! Alex