0

I have a bunch of images that are common for all resolutions (currently I only support one resolution. There are reasons for this).

My question is, when is it appropriate to store images in the assets folder rather than the drawable folder?

MM.
  • 4,224
  • 5
  • 37
  • 74

3 Answers3

0

If you want to access images by their original name, you better save images in the assets folder. Then, you can get them by using:

AssetManager:AssetManager am = getResources().getAssets();
try {
    InputStream is = am.open("image.png");
    // use the input stream as you need
} catch (IOException e) {
    e.printStackTrace();
}

I Hope this helps.

the Tin Man
  • 158,662
  • 42
  • 215
  • 303
Android Stack
  • 4,314
  • 6
  • 31
  • 49
0

you can change the files in assets folder anytime you want and nothing will be effected (i mean the resources of your application by "nothing"). it may be useful to give the name of the image file as a parameter for example.

cagla
  • 538
  • 4
  • 7
0

The difference between a raw resource in res/raw directory and an asset is that assets behave like a file system, they can be listed, iterated over, discovered, just like files while for raw resources, you need the resource ID.

From: http://mylifewithandroid.blogspot.it/2009/06/assets.html (emphasis mine)

Also you may use assets when you need to organize things using sub-folders.

Community
  • 1
  • 1
tacone
  • 11,371
  • 8
  • 43
  • 60