0

In a testcase I need to load a picture which is available in my testproject in the folder

/myproject/res/drawable-hdpi/attachment.png

I tried it already by using the InstrumentationTestCase and storing the file in the /res/raw folder and loading it with this, but the R file does not contain my attachment.png

Context testContext = getInstrumentation().getContext();
InputStream input = testContext.getResources().openRawResource(R.raw.?????????)

any idea?

thanks

Al Phaba
  • 6,545
  • 12
  • 51
  • 83

1 Answers1

1

You should not use raw to save images, used drawable o asset ;)

Difference between /res and /assets directories

Android images in /assets or res/raw

Community
  • 1
  • 1
Gabriel
  • 476
  • 2
  • 11
  • 64
  • 1
    With using the assets folder instead, I could load it this way Context testContext = getInstrumentation().getContext(); InputStream input = testContext.getAssets().open("attachment.png"); – Al Phaba Apr 28 '14 at 14:33