我从网上找的几个程序都使用了这个类,可是我用的sdk1.6里没有这个类,怎么回事??
解决方案 »
- SDK自带的ApiDemo缺少R.java!!
- 求助 看看这样的效果android有没有现成的组件来实现。
- 如何实现QQ登陆界面样式,请教。
- 求高手帮我看下我下面这段获取root权限的代码,为什么还是没有成功
- HorizontalScroll怎么实现下面的效果?
- 安卓阅读器实现长按后选择文字内容,并复制,分享等功能
- R文件一个小问题!!!!!速速进来瞧瞧!
- 如何写个监听屏幕切换的后台服务
- listview在屏幕黑屏解锁后期中item不显示
- 请教安卓有没有开发框架的
- android如何在同一个TextView或者EditText中显示不同大小的字体
- android开发 :摄像头抓取的相片放到SD中,如果SD满了怎么办啊?
SystemProperties是Java语言的类~~~ import java.lang.system 应该就可以了~~
这个类有没有权限限制我不太清楚~~你可以查查看
/*
* Copyright (C) 2006 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/package android.os;
/**
* Gives access to the system properties store. The system properties
* store contains a list of string key-value pairs.
*
* {@hide}
*/
public class SystemProperties
{
public static final int PROP_NAME_MAX = 31;
public static final int PROP_VALUE_MAX = 91; private static native String native_get(String key);
private static native String native_get(String key, String def);
private static native void native_set(String key, String def); /**
* Get the value for the given key.
* @return an empty string if the key isn't found
* @throws IllegalArgumentException if the key exceeds 32 characters
*/
public static String get(String key) {
if (key.length() > PROP_NAME_MAX) {
throw new IllegalArgumentException("key.length > " + PROP_NAME_MAX);
}
return native_get(key);
} /**
* Get the value for the given key.
* @return if the key isn't found, return def if it isn't null, or an empty string otherwise
* @throws IllegalArgumentException if the key exceeds 32 characters
*/
public static String get(String key, String def) {
if (key.length() > PROP_NAME_MAX) {
throw new IllegalArgumentException("key.length > " + PROP_NAME_MAX);
}
return native_get(key, def);
} /**
* Get the value for the given key, and return as an integer.
* @param key the key to lookup
* @param def a default value to return
* @return the key parsed as an integer, or def if the key isn't found or
* cannot be parsed
* @throws IllegalArgumentException if the key exceeds 32 characters
*/
public static int getInt(String key, int def) {
try {
return Integer.parseInt(get(key));
} catch (NumberFormatException e) {
return def;
}
} /**
* Get the value for the given key, and return as a long.
* @param key the key to lookup
* @param def a default value to return
* @return the key parsed as a long, or def if the key isn't found or
* cannot be parsed
* @throws IllegalArgumentException if the key exceeds 32 characters
*/
public static long getLong(String key, long def) {
try {
return Long.parseLong(get(key));
} catch (NumberFormatException e) {
return def;
}
} /**
* Get the value for the given key, returned as a boolean.
* Values 'n', 'no', '0', 'false' or 'off' are considered false.
* Values 'y', 'yes', '1', 'true' or 'on' are considered true.
* (case insensitive).
* If the key does not exist, or has any other value, then the default
* result is returned.
* @param key the key to lookup
* @param def a default value to return
* @return the key parsed as a boolean, or def if the key isn't found or is
* not able to be parsed as a boolean.
* @throws IllegalArgumentException if the key exceeds 32 characters
*/
public static boolean getBoolean(String key, boolean def) {
String value = get(key);
// Deal with these quick cases first: not found, 0 and 1
if (value.equals("")) {
return def;
} else if (value.equals("0")) {
return false;
} else if (value.equals("1")) {
return true;
// now for slower (and hopefully less common) cases
} else if (value.equalsIgnoreCase("n") ||
value.equalsIgnoreCase("no") ||
value.equalsIgnoreCase("false") ||
value.equalsIgnoreCase("off")) {
return false;
} else if (value.equalsIgnoreCase("y") ||
value.equalsIgnoreCase("yes") ||
value.equalsIgnoreCase("true") ||
value.equalsIgnoreCase("on")) {
return true;
}
return def;
} /**
* Set the value for the given key.
* @throws IllegalArgumentException if the key exceeds 32 characters
* @throws IllegalArgumentException if the value exceeds 92 characters
*/
public static void set(String key, String val) {
if (key.length() > PROP_NAME_MAX) {
throw new IllegalArgumentException("key.length > " + PROP_NAME_MAX);
}
if (val != null && val.length() > PROP_VALUE_MAX) {
throw new IllegalArgumentException("val.length > " +
PROP_VALUE_MAX);
}
native_set(key, val);
}
}
把Android SDK 目录下data下的layoutlib.jar文件加到当前工程的附加库路径中,然后在源程序中Import 相应的包即可
如import android.os.SystemProperties;