That's called non-volatile memory. Do you know USB-sticks? That's non-volatile memory also. It keeps its data even when it's in your pocket without any battery.
And, but that's somewhat more technical, so is the BIOS in your laptop: it not only keeps it programs but also your settings even if you remove the battery.
Does anyone remembers any old cell phones model that have only RAM memory and the phone book stored in the RAM?
How it kept the contacts in memory when the battery died?