Loading Properties File in Android [closed]

2019-05-26 06:18发布

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条回答
戒情不戒烟
2楼-- · 2019-05-26 07:02

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.

查看更多
登录 后发表回答