How to save daily data at the end of the day?

Hi guys, 

I`m trying to implement an app that track the amount of cigarette I smoke. Similarly to the Hydration Tracker, I want to manually increase the value for smoked cigarettes and furthermore I want to display the on average smoked cigarettes. 

To achieve this, the app has to save the daily amount at midnight automatically and recalculate the dependent values.

The options I came up with:

Check on the onUpdate() of the App if the Day has changed, if so do the things described above.

 Implement a timer, so the App does the actions at a set time.

I know this question is pretty basic and might even be answered in the forum already, but I couldn't find any information on it.

Thanks in advance,

Best Regards