I am currently stuck with my current code where after setting a reminder with AlarmManager and updating it, it shows up as two notifications instead of just one. That is just the current limitation I have as my intention with the code I had written should allow for more than one notification for different entries stored in sqlite database, but the method I am currently using is unreliable for this reason I had stated above. I have not tried anything as I am not sure how to exactly do as I had mentioned, which I had hoped for advice on how to solve this issue. I also apologize if this is not the right way to ask a question.
For example:
After adding an entry and setting a reminder 2 minutes later,
Title: Cycling
Content: Cycle at the park near the house
and then updating it to:
Title: Cycling
Content: Cycle at the park near the house for 1-2 hours
Desired Output 2 minutes later:
Title: Cycling
Content: Cycle at the park near the house for 1-2 hours
Rather than showing two notifications:
Title: Cycling
Content: Cycle at the park near the house
Title: Cycling
Content: Cycle at the park near the house for 1-2 hours
What I have tried:
In my DatabaseManager.class:
public long reminderCount(){
SQLiteDatabase sqlDB = this.getReadableDatabase();
return DatabaseUtils.queryNumEntries(sqlDB, DatabaseReminder.TABLE_NAME);
}
In my AddActivity.class:
RemID = databaseManager.reminderCount()+1;
remindId = String.valueOf(RemID);
remId = Integer.parseInt(remindId);
AlarmManager alarmManager = (AlarmManager) getSystemService(Context.ALARM_SERVICE);
Intent intent = new Intent(getApplicationContext(), ReminderReceiver.class);
intent.putExtra("DateTime", dateTimePicked);
intent.putExtra("NotifID", remId);
intent.putExtra("Title", titlePicked);
intent.putExtra("Description", descriptionPicked);
PendingIntent addIntent = PendingIntent.getBroadcast(this, remId, intent, 0);
alarmManager.setExactAndAllowWhileIdle(AlarmManager.RTC_WAKEUP, Date.parse(dateTimePicked), addIntent);