从asset中读取文件

来源:互联网 发布:js 取反运算符 编辑:程序博客网 时间:2024/06/05 02:24
//context上下文//filename 文件名//key 文件中数据对应的键值对 键名public static String getString(Context context, String fileName, String key) {        Properties pro = new Properties();        try {            InputStream is = context.getAssets().open(fileName);            if (is == null) {                return null;            }            pro.load(is);            String channel_id = pro.getProperty(key);            if (TextUtils.isEmpty(channel_id)) {                return null;            }            return channel_id;        } catch (Exception e) {        }        return null;    }
//读取drawable,string,layout,dimen等的id//resName对应的键名或者idgetApplicationContext().getResources().getIdentifier(resName, "drawable", mPackageName)
0 0
原创粉丝点击