So, the problem is that I can not figure out how to create multiple alarms, given that the data (time, days of the week) are loaded from SQLite (this is fundamental). One alarm clock without problems: the time from the database is recorded in the calendar, 1 PendingIntent , and if you wish, you can disable it using the .cancel() command and set a new one using the same PendingIntent . But what if there are several alarm clocks and how to distinguish them among themselves for deletion?

    1 answer 1

    When PendingIntent , supply it with a unique number ( unique_id ) that you need to remember.

     PendingIntent pi = PendingIntent.getBroadcast(context, unique_id, i, 0); 

    Later, before deleting, create PendingIntent again with the same number and cancel it.

     alarmManager.cancel(pi); 
    • I correctly understood that in order to remove PendingIntent you need to create a supposedly new one, assign it the same id that was in the old one and cancel it. That is, in fact, is working with the old PendingIntent ? - Ivan
    • @Ivan Yes, this is work with the same 'PendingIntent'. - iramm