title: how to clear previous alarms in alarm manager?
body: <p>i am developing one alert app in that i am using alarm manager concept in that user can select no. of days before to came alert(ex.if he select 5 days the alert will come before 5 days) comparing days list is coming from sqlite data base.i write some code its working problem is that when user changes alarm remainder days(ex.3 instead of 5) before setting(5 days)alarms are not clear total 8 alarms are came(5+3) please anyone resolve my problem.</p>
  
  <pre><code>dbcal.set(currentcal.get(Calendar.YEAR), mnth,dt);
  Log.e("dbCal Alarm","first"+dbcal.getTime());
  if(!dbcal.getTime().before(currentcal.getTime())){
      uniqueno++;
      alarmManager = (AlarmManager) getSystemService(Context.ALARM_SERVICE);
      Intent intent = new Intent(SampledateActivity.this,AlarmReceiver.class);
      PendingIntent pi = PendingIntent.getBroadcast(SampledateActivity.this, uniqueno, intent, 0);
      alarmManager.set(AlarmManager.RTC_WAKEUP, dbcal.getTimeInMillis(), pi);
  }
  for(int k = 1 ; k &lt;= time ;k++){
     Log.e("Entered to alarm","yes");
     dbcal.add(Calendar.HOUR, -24);
     if(!dbcal.getTime().before(currentcal.getTime())){
          uniqueno++;
          Intent intentlocal = new Intent(SampledateActivity.this,AlarmReceiver.class);
          PendingIntent pilocal = PendingIntent.getBroadcast(SampledateActivity.this, uniqueno, intentlocal, 0);
          alarmManager = (AlarmManager) getSystemService(Context.ALARM_SERVICE);
          alarmManager.set(AlarmManager.RTC_WAKEUP, dbcal.getTimeInMillis(), pilocal);
          Log.e("dbCal Alarm","k: "+"k value:"+k+(time*i+k)+":"+dbcal.getTime());
    }
  }
  </code></pre>