I need to store two counters and reset them to zero at midnight.
So far I have it stored as int :
public int wcounter=0;
public int bcounter=0;
that is incremented wcounter++;
by an onclick function.
I need to store two counters
You will want to use SharedPreferences
to store these values. This will make sure they don't get deleted by the system. The Docs have a good example to get you started on ShredPreferences
.
2.
and reset them to zero at midnight
For this part you will probably want to use an AlarmManager
. You may even want to register a BootReceiver
so if the device is restarted, your AlarmManager
will still get triggered.
That should give you an idea of how to get started. You can find good examples and tutorials of each all over SO and The Google.