简体   繁体   English

Android-处理下载的图像文件的最佳方法

[英]Android - best way to handle downloaded image files

I am building an app that shows user's FB friends' location on a map with their profile pic as the map marker icon. 我正在构建一个应用程序,在用户的个人资料图片作为地图标记图标的情况下,在地图上显示用户的FB朋友的位置。

After downloading friends' pics, I stored them on ArrayList on a global application object and then show them on the map. 下载朋友的照片后,我将它们存储在全局应用程序对象的ArrayList上,然后在地图上显示它们。 I've realized that I am spending a lot of heap memory for doing that. 我已经意识到我为此花费了大量的堆内存。

I guess the right way to do it will be by storing them on the external storage, but I am not sure how to do it. 我猜想正确的方法是将它们存储在外部存储中,但是我不确定该怎么做。 Or maybe use SQLite database. 或者使用SQLite数据库。

So my question is, what is the most efficient way to do that process? 所以我的问题是,最有效的方法是什么? keep in mind that when a user's friend connect to the app, the app should show him on the map in real time. 请记住,当用户的朋友连接到该应用程序时,该应用程序应实时在地图上显示他。

Using ArrayList to store images does not scale very well, a better approach would be to store them in a database using Blob as described here: 使用ArrayList来存储图像不能很好地扩展,一种更好的方法是使用Blob将它们存储在数据库中,如下所述:

How to save images into Database 如何将图像保存到数据库

Another way of doing this if you're not too comfortable with object persistance, is saving your images to filesystem and simply storing in a database table the pathnames to the images, so you can retrieve them when needed. 如果您对对象持久性不太满意,可以这样做的另一种方法是将图像保存到文件系统,并简单地将图像的路径名存储在数据库表中,以便您可以在需要时检索它们。

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

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