I could not think of a better way to formulate this question, so let me clarify:
I store a lot of things in Core Data, some of which are images stored as binary data. These images were configured to use external storage, that is, from what I can collect, Core Data takes care of storing these images in a different place on the disk, and not inside the database itself if they are too large (> 1 MB?) . I am also trying to create a simple backup / recovery system for this database using file sharing. Clicking “backup” copies my .sqlite file from the “My Library” folder to the “My Documents” folder (under a different name), allowing the user to access via iTunes (for storage, wherever they are), and clicking “restore” Searches for a backup file in the Documents folder, deletes the active .sqlite file in the Library folder and replaces it with the backup.
The problem arises when an image is deleted from Core Data, but then I want to restore my database until that image still exists. When I delete this image using Core Data, I assume that both the path to the image that is stored in the database and the image itself stored elsewhere are deleted. But when I restore my previous database, returning the .sqlite file, there is only the path to the image - the image itself was stored from the outside, so it was not found anywhere.
First of all, is this a reasonable approach to backing up and restoring a database in Core Data, or is there a clear reason why I should not do this by copying the main .sqlite file back and forth? Secondly, can anyone give some advice on how I can let Core Data take care of external storage while maintaining a way to back up these images? I understand that I could store the images manually, which allows me to back up the image folder along with my .sqlite file, but I like the ease of using Core Data for me, so I'm just wondering if there is any better way to do this operation backup / restore.
source share