Where does Android save properties used by getprop
and setprop
?
What happens when we use setprop
to set a property? Is it written to a persist file, a temporary file, or in memory only?
You can saved your project properties using Shared Preferences
//To save settings
SharedPreferences settings = getSharedPreferences("FileName", Activity.MODE_PRIVATE);
SharedPreferences.Editor editor = settings.edit();
editor.putString("username","hello");
editor.putString("password", "123456");
editor.commit();
//To get Settings
settings.getString("username","");
settings.getString("password","");
or you can use the Application Object to save settings
The files are saved on the applications data storage that is not accessible by other applications as an XML file
EDIT
Property system is an important feature on android. It runs as a service and manages system configurations and status. All these configurations and status are properties. A property is a key/value pair, both of which are of string type. From the sense of function, it's very similar to windows registry. Many android applications and libraries directly or indirectly relies on this feature to determine their runtime behavior. For example, adbd process queries property service to check if it's running in emulator.
How property system works The high level architecture of property system is shown as following.
Most of the values are key value pair so must be XML. More details can be found here
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With