Recently I need to read system property in my Android app development. I checked the Android documents and found that Android has a Systemproperties class to handle this kind of requirement. However, Systemproperties class isn’t a public class of SDK, which means it is invisible to the app developer. My understanding is that Google wants this class to be used for Android source developers rather than application developers.
If I use this class as a source developer, I have to raise my program with root permission and re-build the whole system.
So I applied a trick way to access the Systemproperties method with the help of the Java reflect mechanism.
I studied the source code of SystemProperties.java and found the methods it implemented.
SystemProperties.java
This class defined the set/get methods for the different data types. What I need is the get() method of return a String type.
The rest work is straightforward, I wrote the below codes and inserted them into my class.
About This Article
This article presents an effective way to achieve system property in the Android APP development. Which uses the Java reflect mechanism to access the method of class Systemproperties.