Storing Arraylist Of Points To A File In Java For Android
I am unable to write the ArrayList to a file. I am doing as following, what is the correct way?  If I don't add 'pt' into arraylist, process goes fine and it gets saved. os.writeOb
Solution 1:
To seralize the List<Point>, your Point class must be serializable.
publicclassPointimplementsSerializable {...}
I'd suggest to use JSON (gson) API to read and write objects directly.
Solution 2:
Instead of keeping Points in ArrayList, you can add two Integers per point. Integer supports Serializable, Point does not. 
Solution 3:
android.graphics.Point is not Serializable.
Make a new class PointSerializable which will copy android.graphics.Point in to custom Point class
classPointimplementsSerializable
{
    privatestaticfinallongserialVersionUID=1L;
    privateint x;
    privateint y;
    Point(android.graphics.Point point)
    {
        this.x  = point.x;
        this.y= point.y;
    }
}
Post a Comment for "Storing Arraylist Of Points To A File In Java For Android"