Loading Properties File in Android [closed]

混江龙づ霸主 提交于 2019-12-22 13:55:48

问题


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.



来源:https://stackoverflow.com/questions/17096167/loading-properties-file-in-android

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!