Reputation: 4173
How can one save drawing on canvas in android, so that it could be restored at some point in future? For example, I save current drawing on canvas, then draw something else, and after that restore canvas to the previous saved state.
Upvotes: 0
Views: 2088
Reputation: 75635
Canvas draws on Bitmap
so if that is sufficient, then save your bitmap to file. But if you want to save all user "strokes", you need to record it separately and then replay once loaded.
Upvotes: 1
Reputation: 32269
You have to store the model data separately. In draw method you only define how to draw this data. Depending on the situation you can set a flag and in draw, draw the appropriate model.
You also can save the canvas as a file / bitmap, see for example this: Image on canvas to JPEG file
Upvotes: 1