Android best way to save & load PATH object.


im working on an android app where the user is able to draw onto a canvas.
The userinput is saved inside a Path object, which is than drawn onto the canvas.
What i want to achieve is, that the user can save his drawn input(path object) to load it later on.
So my question is, what is the best way to persist/save and later on load a path object in android.
Can i somehow save the path to an xml or database?
Thanks for your help.

Show source
| java   | android   | save   | path   | load   2016-12-29 15:12 1 Answers

Answers to Android best way to save & load PATH object. ( 1 )

  1. 2016-12-29 15:12

    If you want the user to be able to load those Paths and reuse them, then you should be able to Serializable them with either Java's Serializable interface or your own method of custom saving Path information, from a small google search I found a person who already implemented that using Serializable

    You can start building your solution from that.

    Saving and Loading (Optional)

    Use Gson library to turn your CustomPath into a JSON format (String)


    and then save it in any way you'd like (locally / on the web), also use that library for parsing a JSON format (String) to your CustomPath



    TIP" if you want to keep your saves very small in memory, you should convert your classes to byte[] and then save them in a format that depends on your requirements (ISO_8859_1 or Base64)

Leave a reply to - Android best way to save & load PATH object.

◀ Go back