I have a properties file in my android project but I don't know how to read properties from the file. I have seen several tutorials but those did not help me, in addition I am getting some errors. Would you please post some simple example code to understand how this works?
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
回答1:
Here is some example code...
Properties props=new Properties();
InputStream inputStream =
this.getClass().getClassLoader().getResourceAsStream("example.properties");
props.load(inputStream);
exampleUrl=props.getProperty("baseUrl");
exampleUsername=props.getProperty("username");
examplepassword=props.getProperty("password");
can not help much more without some of your own code. Hope this helps.