Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Where does Android save properties

Tags:

android

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?

like image 398
Cyker Avatar asked Nov 05 '12 04:11

Cyker


1 Answers

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. enter image description here

Most of the values are key value pair so must be XML. More details can be found here

like image 82
Girish Nair Avatar answered Oct 11 '22 12:10

Girish Nair