You can use
Android. provider. settings. system. GetType (key); <br/> Android. provider. settings. system. puttype (key );
The type can be int, float, string, and so on. The key is a constant defined in Android. provider. settings. system. For example, the following code obtains whether the system's wi-fi connection is enabled for static IP settings:
System. getint (contentresolver, system. wifi_use_static_ip) = 1;
However, system. GetType (contentresolver, key) functions throw a settingnotfoundexception exception. That is to say, if the value corresponding to this key cannot be found, an exception will be thrown. we should wrap the above Code with try... catch. Of course, system. GetType (contentresolver, key, DEF) may be more convenient in most cases.
In general, this process is not complicated, but if I look into it, why is it impossible to explicitly write the key in the document at runtime? In fact, I have considered this problem before, but I have not thought much about it. I take it for granted that this API design is just "to make it look more rigorous" (now I think about it, how naive I think, haha ). I didn't understand these settings until today.If the initial default value remains unchanged, their corresponding keys will not exist in the system database.! For example, you have not set the static IP Option ("use static IP" is disabled by default) since your phone leaves the factory (or the last time You reinstall the system ), then wifi_use_static_ip does not exist in the system setting database. That is to say, if the key does not exist, it is also a set state of existence.
Of course, there is no possibility of these keys: Some devices do not implement a function. For example, if a mobile phone does not have a Wi-Fi chip or does not support static IP addresses (for example, only), you can also throw a settingnotfoundexception exception (?) When querying wifi_use_static_ip (??). I am very skeptical about this immature point of view.