I could put a text file in folder res\raw of a library project, but reading it seems to require a Context reference. Could anyone shed some light on this?
Check out my answer here to see how to read file from POJO.
Generally, the res folder should be automatically added into project build path by ADT plugin. suppose you have a test.txt stored under res/raw folder, to read it without android.content.Context:
String file = "raw/test.txt"; // res/raw/test.txt also work.
InputStream in = this.getClass().getClassLoader().getResourceAsStream(file);
I did this before with an old SDK version, it should work with latest SDK as well. Give it a try and see if this helps.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With