3

I have a doubt: if I create an alarm in Android using the AlarmManager, and I reboot the phone, will the alarm still be there, or should I store the alarms in the DB so when the phone is rebooted it'll be created again?

I read the documentation from Android but it doesn't say anything about it (or I just don't understand it). Could anyone please help here?

Thanks a lot in advance!

noloman
  • 9,990
  • 15
  • 77
  • 114
  • possible duplicate of [does Alarm Manager persist even after reboot?](http://stackoverflow.com/questions/12034357/does-alarm-manager-persist-even-after-reboot) – Selvin Jul 05 '13 at 13:46

1 Answers1

1

Alarms do not survive reboot, so you need to register your Application to start on boot and re-register your alarms from what you stored in the database. This has been discussed for example here Clarification of AlarmManager behavior in Android.

Community
  • 1
  • 1
Lukas Ruge
  • 2,044
  • 3
  • 25
  • 41
  • perfect thanks, and what should be an example of the way to store an alarm in the DB? – noloman Jul 05 '13 at 14:25
  • 1
    That depends entirely on how you wan't to do it. I would just store the parameters of the alarm and use a unique request code for the pending intent so you can delete it from the db if it is executed. so the db would contain to numbers for the "type" and the "triggerAtMillis" parameter of the alarm and then more fields depending on what kind of extras you use in your pending intent. For the more general question of how to use databases in android I direct you towards http://www.vogella.com/articles/AndroidSQLite/article.html – Lukas Ruge Jul 05 '13 at 14:35