简体   繁体   English

如何在数据库中保存图像

[英]how to save a image in database

I follow this Instruction and it works. 我遵循此说明 ,它可以工作。

Problem: 问题:

  • Every time I exit my application I need to capture again another image but the image that was been capture is save in the android gallery 每次退出应用程序时,我都需要再次捕获另一个图像,但是已捕获的图像将保存在android gallery中

Question: 题:

  • How can I save the image in database so when I open my application the image will be their. 我如何将图像保存在数据库中,所以当我打开应用程序时,图像就是它们。

Unlike some comments suggest, image format doesn't matter. 与某些注释不同,图像格式无关紧要。 You can either save it as BLOB ( byte[] ) or text (converting it to Base64). 您可以将其另存为BLOB( byte[] )或文本(将其转换为Base64)。

Anyway it's not a good idea to store images in a DB, prefer a file, as argued over here . 无论如何,将图像存储在数据库中而不是文件中并不是一个好主意, 正如本文所讨论的那样

i will advice you get the path at which the image is located at in the android device and load up on your application start. 我会建议您获取图像在android设备中的位置,并在应用程序启动时加载。 the case of saving it in a database is not cool. 将其保存在数据库中的情况并不妙。 that is like consuming the user's memory space on the database side and also the device storage which is not cool. 这就像在数据库侧消耗用户的内存空间,而且还消耗不酷的设备存储。

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

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