Cyker
Cyker

Reputation: 10914

Where does Android save properties

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?

Upvotes: 5

Views: 6065

Answers (1)

Girish Nair
Girish Nair

Reputation: 5216

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

Upvotes: 6

Related Questions