简体   繁体   English

我们可以在SQLite数据库(Android)中存储.doc .pdf和.jpg文件吗?

[英]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??. 是否可以在SQLite数据库中存储像pdf doc这样的文件,并成功再次检索它们。文件必须完好无损并且可以再次读取。我知道我们可以存储图像文件,但对于上述情况?

Even if we can store what will be the given max file size?? 即使我们可以存储什么是给定的最大文件大小?

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. 从SQLite的角度来看,图像与任何其他类型的文件没有什么不同。 You are welcome to store file contents in a BLOB column. 欢迎您将文件内容存储在BLOB列中。 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. SQLite数据库的限制类似于2TB。 Your Android device will not have that much storage space. 您的Android设备将没有那么多的存储空间。

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 : 来自SQLite网站

... 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. ...许多开发人员都惊讶地发现SQLite可以从其数据库中读取和写入较小的BLOB(大小小于约100KB),而不是那些相同的blob可以作为文件系统中的单独文件读取或写入。 (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. (有关详细信息,请参阅比文件系统和内部与外部BLOB快35%。)操作关系数据库引擎会产生开销,但不应假设直接文件I / O比SQLite数据库I / O快,如通常不是。

SQLite is a liteweight component. SQLite是一个重量级的组件。 Instead of storing files like .pdf and .doc in SQLite,store them in internal storage and get the path in internal storage and now store that in SQLite as a string. 不是在SQLite中存储像.pdf和.doc这样的文件,而是将它们存储在内部存储中并获取内部存储中的路径,现在将其作为字符串存储在SQLite中。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM