cancel alarm manager pending intent according to UniqueID android
<p>I am scheduling task and adding alarm manager according to date and time and scheduled task is adding in a list ..when I add any task then it also added in sqlite database and assign a unique id for pendinng intent for alarm manager.</p>

<p>Now if I want to dismisss the alarm then if I remove the row from list then I want to dismiss that particular alarm also.. I am able to delete row from data base but how to dismiss alarm set for that row ?</p>

<p>My code is below :</p>

<pre><code>               Button  AddData=(Button)findViewById(R.id.senddata);
        AddData.setOnClickListener(new View.OnClickListener()
        {
        public void onClick(View v) {
            AlarmManager alarmManager = (AlarmManager) getSystemService(ALARM_SERVICE);                 
            int iUniqueId = (int) (System.currentTimeMillis() &amp; 0xfffffff);

                Date= updatedate.getText().toString();
                Time= updateTime.getText().toString();
                Discripton= discription.getText().toString();
                //---get current date and time---
                Calendar calendar = Calendar.getInstance();       
                //---sets the time for the alarm to trigger---
                calendar.set(Calendar.YEAR, year);
                calendar.set(Calendar.MONTH, month);
                calendar.set(Calendar.DAY_OF_MONTH, day);                 
                calendar.set(Calendar.HOUR_OF_DAY, mHour);
                calendar.set(Calendar.MINUTE, mMinute);
                calendar.set(Calendar.SECOND, 0);
                Log.i("********####",year+"  ,"+month+" , "+day+" , "+mHour+" , "+mMinute+"----"+ calendar.getTimeInMillis());

                Intent intent = new Intent(AddEditExpense.this, TimeAlarm.class);
                //intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_SINGLE_TOP);

                Bundle b12 = new Bundle();
                mStuffresults=Discripton;
                b12.putString("serverresponse", mStuffresults);
                intent.setAction("" + Math.random());
                intent.putExtras(b12);
                PendingIntent displayIntent = PendingIntent.getBroadcast(AddEditExpense.this,iUniqueId,
                intent, PendingIntent.FLAG_UPDATE_CURRENT);
                    alarmManager.set(AlarmManager.RTC_WAKEUP,
                    calendar.getTimeInMillis(), displayIntent);

}
}
</code></pre>

<hr>

<p>pls refer here also: UPDATED</p>

<pre><code>  public boolean onContextItemSelected(MenuItem item) {
        switch(item.getItemId()) {
            case DELETE_ID:
                 UniqueId=AddEditExpense.s;
                 Log.i("UniqueId",UniqueId);
                    Integer i = Integer.valueOf(UniqueId);
                    PendingIntent contentIntent = PendingIntent.getBroadcast(TaskReminder.this, i,
                            new Intent(),PendingIntent.FLAG_UPDATE_CURRENT);
                    AlarmManager alarmManager = (AlarmManager) getSystemService(ALARM_SERVICE);
                    alarmManager.cancel(contentIntent);
                AdapterContextMenuInfo info = (AdapterContextMenuInfo) item.getMenuInfo();
                mDbHelper.deleteNote(info.id);
                fillData();

                return true;
        }
</code></pre>
