Android 项目中的配置文件放在哪里?目前我在 res 目录中创建了一个目录: res/config/configuration.properties
and want to access it as :
properties = new Properties();
properties.load(getClass().getResourceAsStream("config/configuration.properties"));
它不起作用:输入流为空
最佳答案
您可以将其作为 assets/configuration.properties 放置在 assets 目录中
示例代码
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) {
}
关于java - Android项目中的配置属性文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35075619/