here is my code when i'm inserting time and date string in local database then also alarm receiver is set on the time which i insert in local database but the problem is this when i am inserting past time and date string in database it will trigger on current time while the time already passed.it works for latest time and date string
Calendar calender = Calendar.getInstance();
calender.clear();
calender.set(Calendar.MONTH, pickerDate.getMonth());
calender.set(Calendar.DAY_OF_MONTH, pickerDate.getDayOfMonth());
calender.set(Calendar.YEAR, pickerDate.getYear());
calender.set(Calendar.HOUR, pickerTime.getCurrentHour());
calender.set(Calendar.MINUTE, pickerTime.getCurrentMinute());
calender.set(Calendar.SECOND, 00);
SimpleDateFormat formatter = new SimpleDateFormat(getString(R.string.hour_minutes));
String timeString = formatter.format(new Date(calender.getTimeInMillis()));
SimpleDateFormat dateformatter = new SimpleDateFormat(getString(R.string.dateformate));
String dateString = dateformatter.format(new Date(calender.getTimeInMillis()));
AlarmManager alarmMgr = (AlarmManager)getSystemService(Context.ALARM_SERVICE);
Intent intent = new Intent(getApplicationContext(), AlarmReceiver.class);
String alertTitle = mTitleText.getText().toString();
intent.putExtra(getString(R.string.alert_title), alertTitle);
// broadcastCode++;
PendingIntent pendingIntent = PendingIntent.getBroadcast(getApplicationContext(), broadcastCode, intent, PendingIntent.FLAG_UPDATE_CURRENT);
broadcastCode+=1;
alarmMgr.setExact(AlarmManager.RTC_WAKEUP, calender.getTimeInMillis(), pendingIntent);
cv.put(mDbHelper.TIME, timeString);
cv.put(mDbHelper.DATE, dateString);
db.insert(mDbHelper.TABLE_NAME, null, cv);