13

I wonder which way is better to store images in memory:

  • Storing images as BLOB in DB

or

  • Saving images to file and store only path to it in database

What way is more efficient? I suppose that storing files' paths requires more operations because we need to refer to DB and then to file, but I'm not sure if this is less efficent than keeping whole images in DB.

Kamil Lelonek
  • 14,592
  • 14
  • 66
  • 90

1 Answers1

7

In a nutshell:

  • If size of your images are fairly small and number of images are also less, go for storing directly in database, as it is simpler to manage.
  • However, if size of your images in large and also number of images is high, go for saving in file system. Typically, database don't show any performance issues until 10MB for an average mobile.

Let me know if you find any other criteria of judgement.

Gaurav Arora
  • 17,124
  • 5
  • 33
  • 44
  • I'm making sth like news feed so each of them contains simple picture with it. I'll propably decide on solution where I store images in DB as BLOB representation. – Kamil Lelonek Apr 11 '13 at 07:33
  • 6
    See [SQLite's own performance analysis](http://www.sqlite.org/intern-v-extern-blob.html). Keep in mind that it is not Android specific. Wouldn't go for BLOBs that big in size (10MB). So the recommended switch from blob to file accoding to their own site is at a file size of about 100k! – Wolfram Rittmeyer Apr 11 '13 at 14:47