My task is to insert or update some specific data in sqlite based on some condition at 10:00 daily in background. I am stuck. Please Help.
Asked
Active
Viewed 574 times
-1
-
1without any code how to help you.. – Ratilal Chopda Dec 25 '17 at 12:57
-
How to develop a service that runs in background at specific time once in a day..this will resolve my issue. – Raj Dec 25 '17 at 12:58
-
1https://stackoverflow.com/questions/7845660/how-to-run-a-service-every-day-at-noon-and-on-every-boot this should help you – Sachin Rajput Dec 25 '17 at 12:58
1 Answers
0
Make YourReceiver.java
file,
class YourReceiver extends BroadcastReceiver {
@Override
public void onReceive(Context context, Intent intent) {
if (intent.getAction().matches(Intent.ACTION_TIME_TICK)) {
if (check_your_time_with_system_time) {
// update your DB here
}
}
}
}
Register your Receiver
in manifest.xml.
<receiver android:name=".YourReceiver">
<intent-filter>
<action android:name="android.intent.action.TIME_TICK"/>
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</receiver>
The onReceive()
method of YourReceiver
will be called every minute.

Dhruv Patel
- 1,529
- 1
- 18
- 27