Depending on what you need, you can
Loop the Json file and for each entry - do a find on the model for an occurance; if not found - add the entry, if found update or ignore it.
I.e. don't check if empty but rather you will check if the value exist.
If you wanted to replace all - then initialize the model and load all entries.
My requirement is similar, but a little different : I need to take a backup of the existing data stored in the device's sqlite database from time to time so that on an update or reinstall of the app, I can restore the backup. I need to do this from the app itself, not by connecting device to PC. In fact, this latter method cannot be used with an unrooted Android device, not sure about iOS.
So any thoughts and suggestions on how to accomplish it?
Have you tried using Rhom's database_export and database_import (Ruby Only) methods?
Creates a zip archive of a local database partition with all its blob objects, and returns a path to that zip archive.
a local database partition.
Imports the database and blob objects from a zip archive created with
database_export. If the imported archive is inconsistent, or other failure occurs during the import process, the original database will be restored.
the local database partition to be replaced by the zip.
path to the zip archive created with database_export.
Yes, Rob I did try that. The details are in another old thread (sorry can't locate it right now, I'm using my phone email client to reply); but I remember that the export method did not return me the path. I'll check out that old post ASAP. Meanwhile, I'd be thankful if you can show some code snippets for both export and import.