java
- 该API上层应用无法直接使用,可以通过反射,或者导入framework.jar来使用
import android.os.SystemProperties;
SystemProperties.set("persist.lock","true")
String lock = SystemProperties.get("persist.lock")
boolean lock = SystemProperties.getBoolean("persist.lock", false)
C++
#include <cutils/properties.h>
Android.mk 中添加 LOCAL_STATIC_LIBRARIES :=libcutils
int property_get(const char *key, char *value, const char *default_value);
int property_set(const char *key, const char *value);
int property_list....
-----------------------
char prop[PROPERTY_VALUE_MAX]="false";
if(property_get("persist.lock",prop,"false")!=0){
....
}
shell命令设置属性
getprop persist.lock
setprop persist.lock false
其它知识
- 长度限制
#define PROPERTY_KEY_MAX 32 //KEY值
#define PROPERTY_VALUE_MAX 92 //VALUE值
标签:false,SystemProperties,lock,使用,char,persist,const,Android,Properties
From: https://www.cnblogs.com/huuue/p/17909106.html