给android添加系统属性

1.Settings.system

路径:frameworks/base/core/java/android/provider/Settings.java

    public static final String SILVAN_LIU = "TEMP_NAME";  
     public static final String[] SETTINGS_TO_BACKUP ={  
                ~  
           +TEMP_NAME  
                  ~     
    }  

这样添加后,你就是可以通过Settings.System.getInt(getContentResolver(), Settings.System.TEMP_NAME,0) 和Settings.System.getInt(getContentResolver(), Settings.System.TEMP_NAME,0)去得到和设定TEMP_NAME的属性值。

2.SystemProperties

前缀必须用system\core\init\property_service.c中定义的前缀

3 使用举例

    private void handleNotificationForScreenBrightness(boolean plugged) 
	{
		int tmpInt;
		if (plugged)
		{
			tmpInt = Settings.System.getInt(getContentResolver(), Settings.System.SCREEN_BRIGHTNESS, -1);
			SystemProperties.setInt("debug.sf.screen_brightness", tmpInt);
			Settings.System.putInt(getContentResolver(), Settings.System.SCREEN_BRIGHTNESS, 0); 
		}
		else
		{
			tmpInt = SystemProperties.getInt("debug.sf.screen_brightness", 0); //debug.sf.log_repaint
			Settings.System.putInt(getContentResolver(), Settings.System.SCREEN_BRIGHTNESS, tmpInt); 
		}
	}

你可能感兴趣的:(android开发)