Can I serialize the paths drawn on canvas for redrawing the paths on relaunch of the application
I took the reference from
another question here I made few modifications and it worked for me quite well.
To understand we can think we just need to store a map of Actions and Points. We need path.moveTo(int x, int y), path.lineTo(int x, int y),
path.quadTo(int x1, int y1, int x2, int y2) and path.reset() methods for scribbling.
Actions in this case being: lineTo, moveTo, quadTo, reset and points being the corresponding points.
I took two arrays 1 for x and another for y. For quadTo(x1,y1,x2,y2) we need two points, for reset we need no points and for other we need a single point(x,y).
We can think actions being the keys and {arrayX[], arrayY[]} being the value for an action. For actions as lineTo and moveTo size of the arrayX[] and arrayY[] is 1 and for quadTo the size is 2 and for reset the size is 0 (or we can have both the arrays null ) as in that case we need no points. We just need to be careful while retrieving the values of the points from the array corresponding to the Action key. when action is lineTo we just draw the path on the canvas.
Trying to store android.graphics.Path values persistently
I wouldn't recommend to store this kind of data in SharedPreferences as you will have to implement many thinks like getCount() etc which SQLite already offers.
Did you think about using Serialization for your Path objects? You could easily store them in your database afterwards.
Related Topics
Sending a File Using Bluetooth Obex Object Push Profile (Opp)
Android Fab Icon Always Black with Materialcomponents Theme
Fast Ways to Import Drawables in Android Studio
How to Databind to Ontextchanged for an Edittext on Android
Don't Keep Activities - What Is It For
How to Add Button in Actionbar(Android)
Why Do I Get a Emulator-5554 Disconnected Message
Multiple Dex Files Define Lorg/Apache/Cordova/Buildhelper
Android: Making a Fullscreen Application
Rate Google Play Application Directly in App
How to Use Scale Gesture Detector for Pinch Zoom in Android
Pattern "One Activity, Multiple Views": Advantages and Disadvantages
Android 1.5: Reading Sms Messages
How to Build a 'Release' APK in Android Studio