Search code examples
androiddatabaseandroid-serviceandroid-alarmsdashclock

Android Service get data from database on specific time


I have an app show my school timetable, now i trying to write a DashClock widget. I need to get current day subject from database on specific time like everyday 12am so i can publish the update to DashClock. I check AlarmManager, but have no idea how to set the time for run automatically on 12am and how it access to database. Any example or tutorial? Please help, thanks in advance.


Solution

  • You can simply use AlarmManager. By using AlarmManager schedule your task on 12 am at repeating basis. And when AlarmManager Triggers you can perform the database operations.

    There are plenty of examples out there. This SO answer can be a good start. you can also check this project. Followings are jsut some search results samples in google first page.

    link1, link2, link3

    I think from next time better search for your answer before posting.