androidservicealarmmanagerandroid-jobschedulercontentobserver

android- how to check local Sqlite database for new data and push notification continuously?


I have an app for creating and reminding routine tasks that uses sqlite database locally.
I want when a task reaches its time remind the user with a push notification. I worked on a service to check the database if the data & time of the task matches the data & time of the device shows a push notification.
first I decided to uses Job scheduler. but the minimum time for checking the database is 15 minutes.
then I tried Alarm manager for checking the database every one minute. but it seemed a bad idea because of the load of work.
then I read about Content Observer and found out it doesn't tell the exact new data which doesn't work for me.
what should I do? Is there another way or should I stick with Alarm Manager?


Solution

  • Instead of setting a repeating alarm on an interval that checks the database, could you set one exact alarm when the task is scheduled? It executes just when the task is due. And upon a reboot, when your app receives the boot complete intent, it iterates through the database setting all the required one-time alarms?