I'm trying to save my Serialized object when the activity calls the onDestroy() but when i try to write my object using ObjectOutputStream a java.io.NotSerializableExeption is thrown.
Can you please help me. Thanks
I'm trying to save my Serialized object when the activity calls the onDestroy() but when i try to write my object using ObjectOutputStream a java.io.NotSerializableExeption is thrown.
Can you please help me. Thanks
If your object map contains an unserializable object the VM looks for a no argument constructor so as to make an object with the default values and move on. It throws this exception when it can't. The bottom line is that each and every object referenced in your object graph must either:
You do not provide enough specifics for me to go further, but I can't write it for you anyway? In general, you can derive from the unserializable classes or wrap them and provide the necessary functionality. So long as each member meets the conditions I listed, no exception should be thrown.
You need to ensure that the class implements the java.io.Serializable
interface. Also consider using Bundles instead and saving your data in onSaveInstanceState
. For more on data storage, see this dev guide topic.
I encountered same problem and made this class to help the serialization: