Federico Belotti
Federico Belotti

Reputation: 103

Send scheduled notifications according to SQLite database data

I'm making an Android application that reminds the user when he has to take medicines. This app consists of a list of medicines with some attributes: name, format, amount, exp_date, time. For this purpose I created an SQLite database with the table medicines and what I want to do is to send notifications to the user at the time retrieved from the table. I.e. The records in the database have these 3 time values: 11:00, 16:00, 21:00. Whenever the device time and these time values coincide, the app sends a notification to the user every day.

I've already read about AlarmManager, NotificationManger and other stuff but I can't find anything that's kinda specific for me, mostly for the database fetch. I've already created the most part of the app, the only thing missing is the Notification part. So, if someone has an idea or a link that explains in detail how to do it, I will appreciate it.

I hope to have explained myself in detail and I thank you in advance for any help!

Upvotes: 0

Views: 814

Answers (1)

venkatesh venkey
venkatesh venkey

Reputation: 391

create a BroadCastReceiver in your project

public class YourReceiver  extends BroadcastReceiver{

    YourDBhelper mdb;



    @Override
    public void onReceive(Context context, Intent intent) {

        //do stuff what u want 
          mdb = new YourDBhelper(context);//with this u will control of your db

    }
}

and register your reciever in manifest as follows

<receiver android:name="YourReceiver">
      <intent-filter>
         <action android:name="android.intent.action.BOOT_COMPLETED">
      </action>
      </intent-filter>
   </receiver>

Upvotes: 1

Related Questions