For a unit test, I want to open programatically colors.xml and strings.xml from the 'values' folder, in order to compare the entries with those from other files. I tried something like this:
String fileName = "res/strings.xml";
ClassLoader classLoader = getClass().getClassLoader();
File f = new File(classLoader.getResource(fileName).getFile());
if(f.exists()) {
System.out.println("OK");
} else {
System.out.println("not OK");
}
Assert.assertNotNull(f);
It doesn't work - "not OK".
There's no
colors.xml
norstrings.xml
nor evenres/
folder in APK. It's source folder and is not bundled in the app but it used to build one. So you cannot have this opened and read as regular file.