How to transmit data between different android applications ?, Android Transfer
If you develop the android framework, the cooperation between different applications is often involved. You need to read or modify a shared data.
At this time, you can use the following two classes to solve the problem. These two classes are also frequently used in the framework.
SystemProperties, Settings. System
1. Use of SystemProperties.
In the framework, SystemProperties is often used to read or modify system properties. You can use this method to add properties to the system.
The read method is Systemproperties. get (name), and the method for modifying the attribute is Systemproperties. set (name, value ). Attribute names are subject to certain rules. The prefix of names must be written in the format defined in system \ core \ init \ property_service.c,
The following are the rules selected in the service:
{ "net.rmnet0.", AID_RADIO }, { "net.gprs.", AID_RADIO }, { "ril.", AID_RADIO }, { "gsm.", AID_RADIO }, { "net.dns", AID_RADIO }, { "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", AID_SHELL }, { "persist.sys.", AID_SYSTEM }, { "persist.service.", AID_SYSTEM }, { NULL, 0 }
The android system has permission requirements for calling this function:
A. Add android: sharedUserId = "android. uid. system" to the AndroidManifest file"
B. In Android. mk, set LOCAL_CERTIFICATE: = platform.
2. Use of Settings. system.
This is a frequently used class in Settings. It is used to read and modify Settings attributes. Modifications to the Settings attributes usually affect the global function of the mobile phone. To some extent, you can use System. system as the System attribute setting class.
The read method is Settings. System. getInt (contentResolver, name, value); set or modify the attribute method to Settings. System. putInt (contentResolver, name, value );
The data saved in this way is stored in the Settings database. Many Settings in Settings are saved in this way, such as the flight mode.
To use this method, you must register the permission in AndroidManifest.
<uses-permission android:name=”android.permission.WRITE_SETTINGS” />