Saving data during the onPause

The data for the counter are saved at each onPause instead of at every
press to call the database less often.