How do I know if there is new data that I don't have in my local DB or it has been updated?
Well, there can be 2 mechanism for your app to know if there is new data which you need to fetch from the remote server and save to local sqlite
database. Either Push
or Poll
.
Now, which one to use would depend on the situation.
Polling - Lets say user is looking a list of items. The users pulls to refresh, then you might choose to make a call to server to check if there is any new data. Or you may choose to continuously poll for new data continuously, which might not be a great idea since it might consume resources which is unnecessary.
Pushing - When server has a new data, then it can send an FCM push notification with the appropriate data. You can handle the push notification in your app and update the database with the new data. For example, if you have one table only in your local db, you would have unique Id's for each row. You can include the id
and other relevant information in the FCM message and update the corresponding row in your local db.
Decent read: Poll vs. Push - Any reasons to avoid Push Notifications?