Reputation: 6703
I'm using sqlite db in my app and now I would like to allow user customize the background image make them able to select one from their gallery.
Should I just store the path to image and simpy refer to it every time or should I some how transfer the image to some text and store it completely in my db? The second option prevents in case of picture being deleted from gallery. But I would like to know the most appropriate way of doing that.
Upvotes: 1
Views: 88
Reputation: 8281
In my opinion, the best way to save the customized background image is copy it into the internal storage (private storage) of your application. If you store only the path of the file, then file cannot be available once the user deleted that. The official docs saying about the internal storage is:
Upvotes: 2
Reputation: 780
I think it would be better to save only the path of the background, you won't be limited by the size of the image
Upvotes: 2
Reputation: 742
You wouldn't store it as text. Store it as blob to your database. In my opinion this is the way to go (if you use SQLite anyway).
If you have large images then store the path to your storage and not the image to the database.
Upvotes: 3
Reputation: 6459
SQLite has a cursor limit of 1Mb. So, you will probably not be able to store it completely in the DB, when you go to to request it will probably be truncated. Store the path to the image in the database table, and access it that way.
Upvotes: 3