1

I have a mobile app that reads data from a few json files. The app does not modify the data in any way. The data is mostly static but there might be changes (addition/deletion/updates) every few days (5-6 days). These files are around 300-400KB in size.

I want to figure out a good way to store this data in the backend so I do not have to push app updates every time I have to update the static data. I am thinking of versioning the json files on the backend so the client can check if it has the latest version and then download the new file if there's an update.

On the client, I just read the static json into memory. Will that be an issue if the size grows bigger? Should I look into an alternative approach like storing the JSON in a realm DB?

Is there a better approach to sync such static data between the server and the client?

tbag
  • 1,268
  • 2
  • 16
  • 34

1 Answers1

2

You're on the right path about wanting to "check the version" of the json file, since 400kb is not an insignificant size to download every time. There are multiple ways to do this, the simplest may be via exposing an endpoint from your backend that contains the Last Modified date of the json file, and storing a Last Updated date somewhere in your app via SharedPreferences, and only fetching the json file when these values don't match.

josephus
  • 8,284
  • 1
  • 37
  • 57
  • That's a great suggestion. Thanks! – tbag Dec 09 '17 at 17:48
  • At what point in the client app would you check if the client needs to update the data? On app launch? And is it acceptable to keep the app frozen until it's downloaded and synced? – tbag Dec 09 '17 at 21:04
  • 1
    If your app has a splash screen, that's the perfect place to put it. Otherwise I'd say it depends on how critical these updates are. Would the app function properly without it? Schedule it maybe once a day or every few days (JobScheduler/SyncAdapter/AlarmManager). Is it critical to certain features? Add a check before these screens, maybe block with a progress dialog. App wont work without it? Check the version during every API call (maybe with a jwt session token), use Firebase notifications to trigger download even when app is not in use. – josephus Dec 10 '17 at 05:13