Russell Cargill
Russell Cargill

Reputation: 270

Android How to create a recurring task that will happen every friday?

My problem is that I want the application to download some information from my database every week. This is like a new promotion every week and will be updated on the database every Friday.

I know how to check what day of the week it is using the calendar.

But I don't know how to find out when the next occurring Friday will be.

Is it possible to do or should I just make it a weekly check starting the day the application was installed?

Upvotes: 1

Views: 231

Answers (1)

323go
323go

Reputation: 14274

Store the timestamp of your last update in SharedPreferences. Use AlarmManager with INTERVAL_DAY. When it wakes up your app, check if it's Friday, or has been more than 156 hours since the last update. If it is, run your updates.

Alternatively, check the last update time when launching, and if it's been more than a x days since the last update, update then.

Upvotes: 1

Related Questions