Android加载配置文件的几种方法

Android 中有些配置文件需要在代码外面有一下几种:
一、放入了 app/src/main/assets文件中

		//加载配置文件
        Properties props = new Properties();
        InputStream inputStream = context.getAssets().open("config.properties");
        props.load(inputStream);
        String value = props.getProperty("create_a");

二、放入了 app/src/main/res/raw文件中

		//加载配置文件
        Properties props = new Properties();
        InputStream inputStream1 = context.getResources().openRawResource(R.raw.config);
        props.load(inputStream);
        String value = props.getProperty("create_a");

猜你喜欢

转载自blog.csdn.net/yanwenyuan0304/article/details/115167022