[英]What is the best way to store the image in the memory of app?
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. 我在我的应用程序中使用sqlite db,现在我想允许用户自定义背景图片,使他们能够从图库中选择一个。
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? 我应该只存储图像的路径,而simpy每次都引用它,还是应该将图像传输到某些文本并将其完全存储在数据库中? 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.
但我想知道最合适的方法。
SQLite has a cursor limit of 1Mb. SQLite的游标限制为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.
将映像的路径存储在数据库表中,并以这种方式访问它。
You wouldn't store it as text. 您不会将其存储为文本。 Store it as blob to your database.
将其作为blob存储到数据库中。 In my opinion this is the way to go (if you use SQLite anyway).
我认为这是可行的方法(如果仍然使用SQLite)。
If you have large images then store the path to your storage and not the image to the database. 如果图像较大,则将路径存储到存储,而不是将图像存储到数据库。
我认为最好只保存背景的路径,而不会受到图像大小的限制
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:
关于内部存储的官方文档是:
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.