Question

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?

Was it helpful?

Solution

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top