Back to project page androiddevice.info.
The source code is released under:
GNU General Public License
If you think the Android project androiddevice.info listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
package name.unused.android.utils.systemproperties; /*w w w .ja va2 s . com*/ import android.content.Context; import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; import name.unused.android.utils.systemproperties.exception.NoSuchPropertyException; public class SystemProperty { private final Context mContext; public SystemProperty(Context mContext) { this.mContext = mContext; } public String getOrThrow(String key) throws NoSuchPropertyException { try { ClassLoader classLoader = mContext.getClassLoader(); Class SystemProperties = classLoader.loadClass("android.os.SystemProperties"); Method methodGet = SystemProperties.getMethod("get", String.class); return (String) methodGet.invoke(SystemProperties, key); } catch (ClassNotFoundException e) { throw new NoSuchPropertyException(e); } catch (NoSuchMethodException e) { throw new NoSuchPropertyException(e); } catch (InvocationTargetException e) { throw new NoSuchPropertyException(e); } catch (IllegalAccessException e) { throw new NoSuchPropertyException(e); } } public String get(String key) { try { return getOrThrow(key); } catch (NoSuchPropertyException e) { return null; } } }