I have a file defined next to the default.properties, AndroidManifest.xml, called my_config.properties. my question is. how do open this file in my class?
if i move it to the class package i can read it using the folowing code:
Properties configFile = new Properties();
try {
configFile.load(MyConstantsClass.class.getResourceAsStream("my_config.properties"));
} catch (IOException e) {
e.printStackTrace();
}
but in this case the file needs to be inside the same package as the class i use this snippet in. how do i read from it when its defined like in the beggining of my question?
Thank you.
You can only open files from Android that are included in your APK, the current location of the my_config.properties will not be included in there. I would suggest that the right place for this kind of file would be your “assets” directory and you have to use the correct class to access it.