public void deleteOrReschedule(final Context context) { if (isLocationRepeat()) { return; } if (repeats == 0 || time == null) { delete(context); } else { // Need to set the correct time, but using today as the date // Because no sense in setting reminders in the past GregorianCalendar gcOrgTime = new GregorianCalendar(); gcOrgTime.setTimeInMillis(time); // Use today's date GregorianCalendar gc = new GregorianCalendar(); final long now = gc.getTimeInMillis(); // With original time gc.set(GregorianCalendar.HOUR_OF_DAY, gcOrgTime.get(GregorianCalendar.HOUR_OF_DAY)); gc.set(GregorianCalendar.MINUTE, gcOrgTime.get(GregorianCalendar.MINUTE)); // Save as base final long base = gc.getTimeInMillis(); // Check today if the time is actually in the future final int start = now < base ? 0 : 1; final long oneDay = 24 * 60 * 60 * 1000; boolean done = false; for (int i = start; i <= 7; i++) { gc.setTimeInMillis(base + i * oneDay); if (repeatsOn(gc.get(GregorianCalendar.DAY_OF_WEEK))) { done = true; time = gc.getTimeInMillis(); save(context); break; } } // Just in case of faulty repeat codes if (!done) { delete(context); } } }