Android how to get access to raw resources that i put in res folder?


Question

In J2ME, I've do this like that: getClass().getResourceAsStream("/raw_resources.dat");

But in android, I always get null on this, why?

1
51
3/29/2012 12:38:55 PM

Accepted Answer

InputStream raw = context.getAssets().open("filename.ext");

Reader is = new BufferedReader(new InputStreamReader(raw, "UTF8"));
25
4/16/2012 4:01:20 AM

For raw files, you should consider creating a raw folder inside res directory and then call getResources().openRawResource(resourceName) from your activity.


Licensed under: CC-BY-SA with attribution
Not affiliated with: Stack Overflow
Icon