views:

1119

answers:

4

I have to make a dedicated image viewer app for Android 2.x.

There are too many jpeg image files: about 2000~ jpegs, over 100MB.

I want access the image files with their file names, but I couldn't find such an example.

By the way, is it okay to put many image files in /res/drawable folder?

I heard that the android application cannot be installed on sdcard and

the program repository is very small so 100MB app cannot be installed generally.

I found some examples which download the large data files on sdcard online,

but I cannot run a web server to host the data files,

and I must upload the fully packaged program on Android Market. (Should I build one apk file?)

What are the best practices for managing too many resource images (or something) in Android?

A: 

Haven't tried it myself, but looks like this could work:

public BitmapDrawable(Resources res, String filepath);

http://developer.android.com/intl/fr/reference/android/graphics/drawable/BitmapDrawable.html#BitmapDrawable%28android.content.res.Resources,%20java.lang.String%29

Scott Smith
Thanks but this did not work.I could load images with getIdentifier method:int resId = getResources().getIdentifier("com.myprogpkg:drawable/"+filename_without_ext, null, null);imgview.setImageResource(resId);
shkim
+2  A: 

I think you are going to have a hard time convincing users to install a program that is 100 MB into the internal memory of their phones. It would be much better to sideload the images onto the SD card. There are a number of fairly cheap file hosting services available such as Amazon S3.

Also, you should consider allowing the users to download the images in small groups instead of in one large chunk.

jebcor
+2  A: 

The G1 has 256MB of internal storage for applications. Even on the Nexus One there's only 512MB so I think it's unlikely that anyone would want a single application taking up such a high proportion of this storage, so creating a 100MB+ .apk file isn't going to be practical.

You are right that stock android phones cannot run applications from the SD Card. (There are custom firmwares that allow this, but this isn't going to help you as only a small minority of users run these.)

You say that you cannot run a webserver, but unfortunately, I think that's your only real option here. You could dowload the images as needed and cache them on the SD Card if you had them on a webserver somewhere. Configuring a webserver to serve a whole of images is pretty straightforward, although you may need to do some work to stop people looking at the images using a web browser rather than your app if you're charging for it.

Dave Webb
A: 

ImageView iv = new ImageView(context);

iv.setImageResource(R.drawable.icon);

QBJack