Reputation: 8583
I'm trying to serlialize a class I created, it's not working and for some reason I can't see the entire exception when I try to log it (in android), but that's not important...
I have a suspicion what it might be...
I haven't done java programming in many years... but now I seem to remember perhaps serialization is not completely automatic?
could someone please tell me what I have to do? point me in the right direction?
I have a class AccountList, I implemented serializable... it contains an arraylist of class Account ... I implemented serializable on AccountList and Account.. I mean just declared "implements Serializable"
but now I think I vaguely remember that if there is something like arraylist inside this AccountList class, then I must actually write some serialization code by overriding some methods in AccountList ?
what should I do?
Upvotes: 0
Views: 139
Reputation: 63134
An object is serializable if it implements Serializable
and all of its non-transient and non-static fields are serializable. If a serializable object contains a collection, then that connection's elements must also be serializable.
Does you AccountList and Account contain collections who's elements are not serializable?
Upvotes: 1
Reputation: 81724
Serialization is automatic as long as all the objects involved are Serializable
. There are several mechanisms for tweaking how it works, but those are not likely to be relevant for you. Have a look at Account
and AccountList
and make sure all their member variables are Serializable
too. And change your exception-handling code to improve the error display!
Upvotes: 4