I have two counters stored with sharedpreferences and I need to reset them to zero everyday at midnight, I know I have to use alarmmanager but I don't really know how I have to do it, I looked at SO exemples and on the google documentation but can't find a way to do it.
the two counters I have are stored like this:
SharedPreferences.Editor editor = counters.edit();
editor.putInt("wcounter", wcounter);
editor.commit();
how can I reset them at midnight?
Set the alarm somewhere appropriate in your code:
Add
YourBroadcastReceiver
as class and in AndroidManifest. InYourBroadcastReceiver
: