I'm working an iOS app that publishes photos to other users, and the sent photos are not stored on the server.
The user must have the history of his photos and related info.
Should I store the photos in Local DB or in the Photos Gallery?
I'm worried that if the photos are stored in the gallery, the user might delete them without understanding this erases the app's history.
Thank you.
-
2How about just strong them in the document directory of your app? – rckoenes Apr 08 '15 at 15:23
-
@rckoenes Can you please explain why is it better? – thedp Apr 08 '15 at 15:31
-
1You save the image in the app document directory and the file name in the some kind of local database (or coredata). This make loading easier and does not create the overhead of storing the image in the database. – rckoenes Apr 08 '15 at 15:33
-
@rckoenes Is there a chance the files will be deleted by the OS, if the total size gets really big? – thedp Apr 08 '15 at 15:40
-
only if you store them in the caches directory. Files in the document directory should be save. – rckoenes Apr 09 '15 at 08:06
2 Answers
Definitely store the photos in a local file system or data storage solution. Otherwise, the photos will be shared/deleted without your knowledge or even the users knowledge of how they are important. This is also better because you wan't to give the user the ability to store them in their gallery only if they specify it.
With any app, you wan't ultimate control of what happens so that you can guide the user along a certain path. By storing the photos yourself, you get control of the data and can give control to the user as you see fit.
Never believe that the user is going to do what you expect. Or as my favorite saying goes, "always design for the dumbest user and you will have designed for all".

- 993
- 1
- 12
- 25
-
1A database is a poor choice for saving images. Simply store the images as files. – rmaddy Apr 08 '15 at 15:30
-
I wasn't meaning an SQL or other databases exactly as much as the concept of a local storage for you images. I am very aware that storing photos or other media data in a database ins't a good idea. I'll make the edit to be more clear. Thanks. – ChristopherW Apr 08 '15 at 15:32
-
I should just store them in the app's directory, and manage the related info in the local DB? – thedp Apr 08 '15 at 15:33
-
1Anyway you can manage the files should be enough. Your app I assume would have references to file names and you can just search your local system for the file as needed. This depends on how your system is designed, but as long as you have the name, you can find the file. – ChristopherW Apr 08 '15 at 15:35
My recommendation would be Core Data, since it works great since on iOS applications. You can find a lot of tutorials out there on the web ( http://www.raywenderlich.com/ for instance ). Since iOS 8 there are a lot of improvements like batch jobs.

- 7,888
- 3
- 34
- 46
-
1A database is a poor choice for saving images. Simply store the images as files. – rmaddy Apr 08 '15 at 15:30
-
Based on my experience it depends. You can use BLOBs in Core data if there are some images that are not large. It is expensive for memory, of course, to use database for storage of 100 files with 2-3 MB size. In the end it all depends on various use cases. For a lot of images it is better to simply save image name and use it like you said – Miknash Apr 08 '15 at 15:33
-
The images are around 1MB, but they might accumulate if the user doesn't delete them from within the app. – thedp Apr 08 '15 at 15:37
-
1if that's the case follow @cmw2379 solution. You might want to look at this as well: http://stackoverflow.com/questions/14531912/storing-images-locally-on-an-ios-device – Miknash Apr 08 '15 at 15:40