- 用ResourceBundle获取
ResourceBundle bundle = ResourceBundle.getBundle("gradle");
String result = bundle.getString("test_key");
- 用Properties 获取
Properties properties = new Properties();
InputStream is = this.getClassLoader().getResourceAsStream("gradle.properties");
properties.load(is);
String result= properties.getProperty("test_key");
本来想通过以上查找的方式获取gradle.properties文件中的数值,进行定制化开发app,结果两种方式都不行,第一种是需要一个汉语的properties文件,这个文件时创建项目时自带的,我没思路;第二种方式path不知道怎么获取,因为这个文件是在根目录的而不是在resource目录下,目前先不想弄了,换了个思路,放在buildConfig里边了
参考AS获取asset文件夹下properties文件中的值这篇文章