Q:

How to fire local notifications one day before event is due Android

I have a native Android to-do app. I want to show local notifications to the user one day before an event starts. 
I have checked the AlarmManager, Broadcast Receivers and Services but I don't have a clear understanding of them.
Can you point me in the right direction? I have to scan continously in my SQLite DB if I have events for tomorrow to inform the user, even when the app is not in the foreground.

A:

You can schedule tasks easily with Java's TimerTask. I pulled the following code example from this tutorial
public class JavaReminder {
Timer timer;

public JavaReminder(int seconds) {
    timer = new Timer();  //At this line a new Thread will be created
    timer.schedule(new RemindTask(), seconds*1000); //delay in milliseconds
}

class RemindTask extends TimerTask {

    @Override
    public void run() {
        System.out.println("ReminderTask is completed by Java timer");
        timer.cancel(); //Not necessary because we call System.exit
        //System.exit(0); //Stops the AWT thread (and everything else)
    }
}
//Do this in your launch activity, or a class specified in androidmanifest to run immediately
public static void main(String args[]) {
    System.out.println("Java timer is about to start");
    JavaReminder reminderBeep = new JavaReminder(5);
    System.out.println("Remindertask is scheduled with Java timer.");

}

}
Read more: http://javarevisited.blogspot.com/2013/02/what-is-timer-and-timertask-in-java-example-tutorial.html#ixzz3XCtfeJwc
Keeping track of time is actually not a trivial task. You don't need to keep looking at your sqlite database, just get it once and keep it up to date in your app. I recommend against using System time, because that may change; instead try pulling time from online. I recommend joda time for your time calculations.

