Development of the application will have some may become a value, such as WebService address application of some IDs, etc., has been directly in the application of the code, not forget the point that, then think of the properties can be used configuration file, I put the URL and other variables configured in the configuration file, After that, you can change the configuration file directly, you do not need to change the code
Let's talk about the use of properties
Copy Code code as follows:
public static string Getpropertiesurl (context C, String s) {
String URL = null;
Properties Properties = new properties ();
try {
Properties.load (C.getassets (). Open ("property.properties"));
url = properties.getproperty (s);
catch (Exception e) {
E.printstacktrace ();
}
return URL;
}
Here I put the configuration file in the Assets folder, you can also be placed under raw or with our Java file siblings so we can read the properties of the value of the
The configuration file is written very simply:
For example Url=www.jb51.net on line comment with # #