Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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??

like image 511
Prasanth Perumal Avatar asked Mar 12 '15 11:03

Prasanth Perumal


2 Answers

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.

like image 164
dcatteeu Avatar answered Nov 19 '22 18:11

dcatteeu


I know we can store image files but for the above?

From the standpoint of SQLite, an image is no different than any other type of file. You are welcome to store file contents in a BLOB column. This may not be very efficient.

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

The limit of a SQLite database is something like 2TB. Your Android device will not have that much storage space.

like image 12
CommonsWare Avatar answered Nov 19 '22 18:11

CommonsWare