If you do the development of the framework of Android, it will often involve the cooperation between different applications and need to read or modify a shared data.
At this point you can use the following two classes to solve the problem, the use of the two classes in the framework also has a regular appearance.
Systemproperties,settings.system
the use of 1.SystemProperties.
In the framework, systemproperties, which is commonly used to read or modify system properties, can be used to add properties to the system.
Where the Read method is systemproperties.get (name), the method to modify the property is systemproperties.set (name, value). The name of the property has a certain rule, and the prefix of the name is written in theformat defined in S ystem\core\init\property_service.c .
The following are the rules that are selected in the service:
{"Net.rmnet0.", Aid_radio}, {"Net.gprs.", Aid_radio}, {"Ril.", Aid_radio}, {"GSM.", Aid_radio}, {"Net.dns", Aid_ra DIO}, {"Net.usb0", Aid_radio}, {"Net.", Aid_system}, {"Dev.", Aid_system}, {"Runtime.", Aid_system }, {"HW.", Aid_system}, {"sys.", Aid_system}, {"Service.", Aid_system}, {"WLAN.", Aid_system}, {"DHCP.", Aid_system}, {"DHCP.", Aid_dhcp}, {"Debug.", Aid_shell}, {"Log.", Aid_shell}, {"Service.adb.root", C17/>aid_shell}, {"Persist.sys.", Aid_system}, {"Persist.service.", Aid_system}, {NULL, 0}
The Android system has permission requirements for methods that call this function:
A. Add android:shareduserid= "Android.uid.system" to the Androidmanifest file
B. In android.mk, set the Local_certificate:=platform.
the use of 2.settings.system.
This is a class commonly used in settings to read and modify settings properties, and changes to settings properties often affect the global functionality of the phone. So in a way, you can use System.system to set the class as a system property.
The Read method is Settings.System.getInt (contentresolver, name, value); Set or modify the property method to Settings.System.putInt (Contentresolver, name, Value);
The data stored in this way is stored in the settings database, and many of the settings in settings are saved in this way, such as airplane mode.
Use this method to register permissions in Androidmanifest
<uses-permission android:name= "Android.permission.WRITE_SETTINGS"/>
How do I pass data between different Android apps?