upon backpressing at addnewalarm fragment creating new record
This is expected behaviour - pressing the "Add New Alarm" FAB creates a new Alarm and immediately takes you to its Edit page.
Why is this happening btw?,.. Can you please tell me how to resolve it!
There's nothing to resolve - it's how the app works.
If you want to change that behaviour, you can modify AddEditAlarmActivity. You can see in there that it creates a new Alarm entry as soon as the FAB is pressed on the Alarms list page:
private Alarm getAlarm() {
switch (getMode()) {
case ADD_ALARM:
final long id = DatabaseHelper.getInstance(this).addAlarm();
LoadAlarmsService.launchLoadAlarmsService(this);
return new Alarm(id);
You'll just need to defer this until the Alarm is saved.
Sir really appreciate your quick response but don't know how to defer this... Please can you tell me what to change in AddEditAlarmActivity and AddEditAlarmFragment classes. Because when i commented this case lines it shows error in the AddEditAlarmFragment class . Waiting for your response. Thanks & Regards
You'll have to defer this code until the alarm is saved, means you'll have to create the Alarm instance in the save() function which actually saves the alarm..
Thanks @smfahadhassan