0

I have lots of Images in my app right now i put all in drawable. images have been pre-compressed/optimized for mobile viewing. (But I want these all images in sdcard and use that location instead of drawable. because of large amount of images)

One of my requirements is that I be able to provide offline access for users. I am wondering what would be the most efficient way

of storing a large amount of images (around four hundred-several thousand)

So My Plan is that I will Store all images in sdcard(by making a folder in it) and now store link of these images in data base Table.

So App first fetch image path from DB Table then fetch file from sdcard and display it.

But my problem is Where should i put these images while developing app.

(Should i put all my images in drawable and then copy it sdcard programitically and then start using that location !!! )

1) How to store all these images in sd-card at the time of development of application. ? 2) So when I will deploy my app these all images should available inside package ?

4

2 回答 2

1

如果您有大量图像,那么在第一次启动应用程序时,从远程位置下载图像并将它们存储在您的 SD 卡上并构建您的数据库表。将它们放在您的可绘制对象中然后将它们复制到您的 SD 卡是没有意义的。

编辑

如果您想从可绘制对象中复制图像并将其存储在 SD 卡上,那么您可以这样做 -

您必须首先将可绘制对象转换为位图对象。

Bitmap bmp = BitmapFactory.decodeResource(context.getResources(), R.drawable.filenameindrawable);

现在使用 FileOutputStream 将其存储在您的 SD 卡上

try {
       FileOutputStream out = new FileOutputStream("file on sd card");
       bmp.compress(Bitmap.CompressFormat.PNG, 90, out);
} catch (Exception e) {
       e.printStackTrace();
}

虽然这不是推荐的方式。

于 2013-01-21T11:48:44.233 回答
0

在 SD 卡上存储应用程序图像不是一个好主意。因为如果有人在您的应用程序安装后没有 sd 卡或移除了 sd 卡,这些图像将无法用于 uor 应用程序。并且任何人都可以访问存储在 sd 卡中的那些图像。因此,投注者通过从远程位置下载图像并将它们存储在您的 SD 卡/内部文件系统上并更新您的数据库表,在应用程序首次启动时将这些图像存储在应用程序的内部文件系统中。

于 2013-01-21T11:59:29.513 回答