android persist attribute use

Persit property

1. Set the prefix The prefix defined
in system\core\init\property_service.c, and set the permissions

2. Add a property and add the default property: For example: silvan_liu

  Path: system/core/rootdir/int.rc

  In the on post-fs-data directory

  setprop persist.sys.silvan_liu 1 //persist.sys prefix name; 1 is the initial value
3. If the property name starts with "persist.", when setting this property, its value will also be Write /data/property

4. Property usage
In C++, the two functions corresponding to JAVA are property_set and property_get. In fact, JAVA calls these two functions through JNI
1) The JAVA code is as follows:
  import android.os.SystemProperties;

  SystemProperties .set("persist.sys.language", zone.getID());
  String lang= SystemProperties.get("persist.sys.language");
   
   boolean get method:

  boolean fastfoodenable = SystemProperties.getBoolean("persist.sys. fastfoodenable", false);

  boolean setting method:

  SystemProperties.set("persist.sys.fastfoodenable", "true");
5. C code call
  #include <cutils/properties.h>
  property_set("persist.sys.language", "zh");
  property_get("persist.sys.language", propLang, "en");

  In adb shell, you can read and modify by the following names

  #getprop persist.sys.language
  #setprop persist.sys.language zh

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326033043&siteId=291194637