Can we store .doc .pdf and .jpg files in SQLite Database (Android)?

Prasanth Perumal picture Prasanth Perumal · Mar 12, 2015 · Viewed 22.7k times · Source

Is it possible to store files like pdf doc in SQLite db and the retrieve them again successfully.the files must be intact and readable again.I know we can store image files but for the above??.

Even if we can store what will be the given max file size??

Answer

dcatteeu picture dcatteeu · Aug 28, 2017

Yes, go ahead. It is easier to store every file in the database, than just using the database to keep track of where each file is.

If the files are small, performance should be fine. From the SQLite website:

... many developers are surprised to learn that SQLite can read and write smaller BLOBs (less than about 100KB in size) from its database faster than those same blobs can be read or written as separate files from the filesystem. (See 35% Faster Than The Filesystem and Internal Versus External BLOBs for further information.) There is overhead associated with operating a relational database engine, however one should not assume that direct file I/O is faster than SQLite database I/O, as often it is not.