Android:从Deploy.properties或manifest.xml检索自定义属性

时间:2010-05-05 12:05:12

标签: android

我想知道,我们是否可以在Manifest中添加自定义配置或部署属性?如果是,请提供示例。

感谢, 拉梅什

1 个答案:

答案 0 :(得分:0)

将.properties文件放入/ res / raw目录

try {
    Resources resources = this.getResources();
    // Check generated R file for name oy your resource
    InputStream rawResource = resources.openRawResource(R.raw.resourceFileName);
    Properties properties = new Properties();
    properties.load(rawResource);
    System.out.println("The properties are now loaded");
    System.out.println("properties: " + properties);
} catch (NotFoundException e) {
    System.err.println("Did not find raw resource: "+e);
} catch (IOException e) {
    System.err.println("Failed to open property file");
}

来源:http://myossdevblog.blogspot.com/2010/02/reading-properties-files-on-android.html