At the back of the eye on the retina, there are two types of photoreceptors (cells which detect light). Cones deal with colour and fine detail and act in bright light, while rods deal with vision in low-light situations. In the first few minutes of moving into a dark room, cones are responsible for vision but provide a poor picture. Once the rods become more active (they are initially slow to react), they take over and create a much better picture in poor light. Once you move back into light, the rods are reset and so dark-adaption will take a few moments again. Soldiers are trained to close or cover one eye at night when moving in and out of a bright room, or when using a torch, to protect their night vision. Once back in the dark, they reopen the closed eye with the rods still working and, as a result, maintain good vision. Give it a try next time you get up in the middle of the night.
Answered by HIW contributor Aneel Bhangu.