I often see the following code
canvas.save().
canvas translate or rotate
some drawing
canvas.restore
I don\'t understand why we save and then
What's the point of undoing what we just did!
You're not, though. If you're just going off the words, it does sound like that's what might happen, but it actually isn't.
Think of it like this:
You have a series of really complex translations and rotations you want to apply in the same onDraw(Canvas) call. Now, since every translation/rotation you apply to the Canvas happens in order, you would have to undo your last adjustments to the Canvas, or somehow calculate your new adjustments based off the previous one before drawing whatever it is you want to draw. That would get very messy, very quickly.
Using canvas.save() and canvas.restore() is a ridiculously easy way to simplify that process.
By doing adjustments that apply to the Canvas within a save/restore block, you're effectively isolating said adjustments so that whatever you want to draw next won't be affected by what you're drawing now.
Now, a little better explanation of the names:
canvas.save() is saying that I want to save the state of the current Canvas's adjustments so that I can go back to it later.
canvas.restore() is saying that I want to revert my Canvas's adjustments back to the last time I called cavas.save()
The beauty of this is in its simplicity. If you already drew whatever it is you wanted to draw during the save/restore block and you no longer need those adjustment's for your next drawing, using this let's you throw away those unnecessary adjustments and return to the state you want to start your next drawing from.
Hopefully that helps explain it!