Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Currently, I'm loading images as follows:

sampleimage= BitmapFactory.decodeResource(context.getResources(), R.drawable.sampleimage);

This automatically chooses the correct image from the drawable-hdpi, drawable-mdpi or drawable-ldpi folders.

How can I load the bitmap using the image name as the string "sampleimage.png"?

share|improve this question
up vote 3 down vote accepted

If you want to access bitmaps by full file name you can store them in assets folder. Then obtain AssetManager from your Activity by calling getAssets() and use fileName) or AssetManager.openFd(...) method.

If you only want to force Android to not get bitmap from mdpi, ldpi and hdpi folders (depending on device parameters) then store your resources in res/drawable folder (without "-*dpi" suffix). You can also provide bitmaps in res/raw folder and then they wouldn't be scaled (what may occure in res/drawable folder).

There is one more difference between assets and res/drawable or res/raw folder. In assets resources can be put in subfolders in your way of organizing thins.

Look for more info at and

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.