简体   繁体   English

如何在 Android 应用程序编程中从数据库中存储和检索图像

[英]How to store and retrieve images from database in Android app programming

I am new to Android app programming.我是 Android 应用程序编程的新手。 I created one activity which contains a bottom navigation bar (with 3 buttons) and fragments.我创建了一个包含底部导航栏(带有 3 个按钮)和片段的活动。 If you click on the first button, the user profile will appear.如果单击第一个按钮,将显示用户配置文件。 Now I would like the user to chose an image from his device.现在我希望用户从他的设备中选择一个图像。 This image should be saved in a database and this is exactely the point I got stucked.这张图片应该保存在数据库中,这正是我卡住的地方。 Which database is used in app programming and what api I will need to store and retrieve images from that database so that I can put it into an ImageView.应用程序编程中使用哪个数据库以及 api 我需要从该数据库存储和检索图像,以便我可以将其放入 ImageView。 I hope somebody can be of further help.我希望有人可以提供进一步的帮助。 Thanks!谢谢!

If this is just for fun, store it locally on the device.如果这只是为了好玩,请将其本地存储在设备上。 If this is for enterprise, send the image data over TCP, or some reliable protocol, to a remote server to be stored in a database.如果这是针对企业的,请通过 TCP 或一些可靠的协议将图像数据发送到远程服务器以存储在数据库中。 You can use relational, or non relational.您可以使用关系或非关系。

Here is how to do it without a server How to display the image from database in android imageview这是在没有服务器的情况下如何操作如何在 android imageview 中显示数据库中的图像

I assume you want to store the image on cloud and then retrieve it based on user, for this best option is to go for firebase, you can use firebase realtime database to store data and firebase storage to store files such as PDF or images. I assume you want to store the image on cloud and then retrieve it based on user, for this best option is to go for firebase, you can use firebase realtime database to store data and firebase storage to store files such as PDF or images. For example you can store image in firebase storage and store it's URL in firebase realtime database along with user details.例如,您可以将图像存储在 firebase 存储中,并将其 URL 与用户详细信息一起存储在 firebase 实时数据库中。

Here is documentation for firebase:- https://firebase.google.com/docs/android/setup How to setup app with firebase and all the APIs you can use to read/write to firebase. Here is documentation for firebase:- https://firebase.google.com/docs/android/setup How to setup app with firebase and all the APIs you can use to read/write to firebase.

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

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