Issue
Where can I place configuration file in Android project? Currently I am made a directory in res directory as : res/config/configuration.properties
and want to access it as :
properties = new Properties();
properties.load(getClass().getResourceAsStream("config/configuration.properties"));
It is not working : input stream is null
Solution
You can place it in assets directory as assets/configuration.properties
Example code
try {
InputStream is = context.getAssets().open("configuration.properties");
Properties props = new Properties();
props.load(is);
String value = props.getProperty("key", "");
is.close();
} catch (Exception e) {
}
Answered By - Minh Quy
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.