3

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.

Venks88
  • 73
  • 6
  • Somehow, I achieved it. I took the co-ordinates from the gesture, put them in an array and serialized it. And the other side, I de-serialized it and reconstructed the gesture. cool.. – Venks88 Mar 08 '13 at 10:50
  • 2
    I am stuck on this same problem. Could you post the code of how you solved this? Thanks! – Deekor Oct 20 '13 at 05:55

0 Answers0