Issue
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?
Solution
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.
Answered By - yorkw
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.