Android-C代码获取系统属性

1.添加头文件:

#include <cutils/properties.h>

2.


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) {
    ...
}

3.Android.mk添加:

LOCAL_STATIC_LIBRARIES :=libcutils

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值