I need to serialize and deserialize android.graphic.Path object. The below code (I am using) serializes and deserializes an Object
public static byte[] serialize(Object obj) {
ByteArrayOutputStream out = new ByteArrayOutputStream();
ObjectOutputStream os = new ObjectOutputStream(out);
os.writeObject(obj);
return out.toByteArray();
}
public static Object deserialize(byte[] data) {
ByteArrayInputStream in = new ByteArrayInputStream(data);
ObjectInputStream is = new ObjectInputStream(in);
return is.readObject();
}
In deserializing method, is.readObject() is returning null. Some how, I came to know that the problem is "android.graphics.Path class doesn't implement Serializable interface".
I tried creating a custom class which extends android.graphics.Path and implements Serializable interface. Still no luck. I already checked some answers in StackOverFlow.com, but, no use.
Does anyone have a solution for this? If yes, please post the code.