private long saveAlarm() { Alarm alarm = new Alarm(); alarm.id = mId; alarm.enabled = mEnabledPref.isChecked(); alarm.hour = mHour; alarm.minutes = mMinutes; alarm.daysOfWeek = mRepeatPref.getDaysOfWeek(); alarm.vibrate = mVibratePref.isChecked(); alarm.label = mLabel.getText(); alarm.alert = mAlarmPref.getAlert(); long time; if (alarm.id == -1) { time = Alarms.addAlarm(this, alarm); // addAlarm populates the alarm with the new id. Update mId so that // changes to other preferences update the new alarm. mId = alarm.id; } else { time = Alarms.setAlarm(this, alarm); } return time; }