1

I am writing android application which will request the data from the server after every 5 minutes and will load it into the sqlite. Later on, the data from the sqlite will be displayed to the user whenever he wants to view the data. Database will contain only the data up to last 2 days and will keep deleting the older data.

I want to achieve all this functionality using Firebase JobScheduler. But before writing, I want to know if it is the right tool to go for? Is there a better way to achieve this functionality? Or any recommended way?

Thanks in advance.

user2908751
  • 195
  • 1
  • 2
  • 8

2 Answers2

0

Your implementation plan sounds OK to me. But I think synchronizing every 5 minutes is excessive and will cause problems for your users from constant battery drain and network usage.

Doug Stevenson
  • 297,357
  • 32
  • 422
  • 441
  • 5 minutes is our initial plan; we will set it configurable for user. But the minimum will be 5 minutes in any way. I know it's not a good with respect to battery and network but our data is such critical that even 5 minutes are too much. But is there a better way to achieve all this? – user2908751 Jan 23 '18 at 15:44
  • Not that I know of. – Doug Stevenson Jan 23 '18 at 15:46
0

You implementation is right but there is a huge drawback in this mechanism i.e. battery drainage. I think the best mechanism would be if you implement that functionality on server end.

  1. Server checks that if there is any change in the database
  2. If it finds any change then you just need to push the specific updated data to your mobile agent.

Advantage:
1. You dont need to worry about the battery on mobile agent 2. All the hard work and calculation is done on server end.

Enjoy !!

Shah
  • 385
  • 1
  • 6
  • 15
  • I just got a thought to start the service after every 5 minutes, get the updates from the API and then stop the service. Is that possible? – user2908751 Jan 23 '18 at 16:09
  • yes thats possible then you will start the service again and then so forth. Personally I would not recommend it. – Shah Jan 23 '18 at 16:20