Mike的分享空间
date: 2013.07.09; modification:2013.07.09
目录:
Android提供了一套系统参数设置和获取的方法,这些参数可以在android系统中静态或动态的设定和获取。
getprop “key”
setprop "key" "value"
代码定义在:
system/core/libcutils/properties.c #define PROPERTY_KEY_MAX 32 #define PROPERTY_VALUE_MAX 92 int property_get(const char *key, char *value, const char *default_value); int property_set(const char *key, const char *value); int property_list(void (*propfn)(const char *key, const char *value, void *cookie), void *cookie);
使用:
#include "cutils/properties.h" char prop[PROPERTY_VALUE_MAX] = "000"; if(property_get("prop_name", prop, NULL) != 0) { ... }
说明:
frameworks/base/core/java/android/os/SystemProperties.java
public static final int PROP_NAME_MAX = 31; public static final int PROP_VALUE_MAX = 91; public static String get(String key) ; public static String get(String key, String def) ; public static int getInt(String key, int def) ; public static long getLong(String key, long def) ; public static boolean getBoolean(String key, boolean def) ; public static void set(String key, String val) ; public static void addChangeCallback(Runnable callback) ;