public boolean onPreferenceChange(Preference preference, Object newValue) {
   Log.v(TAG, "Setting Primary Storage to " + (String) newValue);
   if (newValue.equals("sdcard1")) {
     Utils.writeValue(
         FILE,
         "export EXTERNAL_STORAGE /storage/sdcard1" + System.getProperty("line.separator"),
         false);
     Utils.writeValue(
         FILE,
         "export SECONDARY_STORAGE /storage/sdcard0" + System.getProperty("line.separator"),
         true);
   } else if (newValue.equals("sdcard0")) {
     Utils.writeValue(
         FILE,
         "export EXTERNAL_STORAGE /storage/sdcard0" + System.getProperty("line.separator"),
         false);
     Utils.writeValue(
         FILE,
         "export SECONDARY_STORAGE /storage/sdcard1" + System.getProperty("line.separator"),
         true);
   }
   /**
    * Utils.showDialog((Context)this, "Reboot Required!", "Reboot required before changes will take
    * effect!"); *
    */
   return true;
 }
 @Override
 public boolean onPreferenceChange(Preference preference, Object newValue) {
   Boolean enabled = (Boolean) newValue;
   if (enabled) Utils.writeValue(FILE, "1\n");
   else Utils.writeValue(FILE, "0\n");
   return true;
 }
  public static void restore(Context context) {
    SharedPreferences sharedPrefs = PreferenceManager.getDefaultSharedPreferences(context);
    boolean light = sharedPrefs.getBoolean(DeviceSettings.KEY_TOUCHKEY_LIGHT, true);

    Utils.writeValue(FILE_TOUCHKEY_DISABLE, light ? "0" : "1");
    Utils.writeValue(FILE_TOUCHKEY_BRIGHTNESS, light ? "1" : "2");
  }
  /**
   * Restore Logo2Menu setting from SharedPreferences. (Write to kernel.)
   *
   * @param context The context to read the SharedPreferences from
   */
  public static void restore(Context context) {
    if (!isSupported()) {
      return;
    }

    SharedPreferences sharedPrefs = PreferenceManager.getDefaultSharedPreferences(context);
    boolean enabled =
        sharedPrefs.getBoolean(TouchscreenFragmentActivity.KEY_LOGO2MENU_SWITCH, false);
    if (enabled) Utils.writeValue(FILE, "1\n");
    else Utils.writeValue(FILE, "0\n");
  }
  /**
   * Restore BLNTimeout setting from SharedPreferences. (Write to kernel.)
   *
   * @param context The context to read the SharedPreferences from
   */
  public static void restore(Context context) {
    if (!isSupported()) {
      return;
    }

    SharedPreferences sharedPrefs = PreferenceManager.getDefaultSharedPreferences(context);
    Utils.writeValue(FILE, sharedPrefs.getString(DeviceSettings.KEY_BLN_TIMEOUT, "60000"));
  }
  /**
   * Restore panel temp setting from SharedPreferences. (Write to kernel.)
   *
   * @param context The context to read the SharedPreferences from
   */
  public static void restore(Context context) {
    if (!isSupported()) {
      return;
    }

    SharedPreferences sharedPrefs = PreferenceManager.getDefaultSharedPreferences(context);
    Utils.writeValue(FILE, sharedPrefs.getString(DeviceSettings.KEY_PANEL_COLOR_TEMPERATURE, "2"));
  }
  /**
   * Restore s-pen setting from SharedPreferences. (Write to kernel.)
   *
   * @param context The context to read the SharedPreferences from
   */
  public static void restore(Context context) {
    if (!isSupported()) {
      return;
    }

    SharedPreferences sharedPrefs = PreferenceManager.getDefaultSharedPreferences(context);
    Utils.writeValue(
        FILE, sharedPrefs.getBoolean(DeviceSettings.KEY_SPEN_POWER_SAVING_MODE, false) ? "1" : "0");
  }
  @Override
  public boolean onPreferenceTreeClick(PreferenceScreen preferenceScreen, Preference preference) {

    String key = preference.getKey();
    Log.w(TAG, "key: " + key);

    if (key.compareTo(DeviceSettings.KEY_TOUCHKEY_LIGHT) == 0) {
      if (((CheckBoxPreference) preference).isChecked()) {
        Utils.writeValue(FILE_TOUCHKEY_DISABLE, "0");
        Utils.writeValue(FILE_TOUCHKEY_BRIGHTNESS, "1");
        preferenceScreen.findPreference(DeviceSettings.KEY_TOUCHKEY_TIMEOUT).setEnabled(true);
      } else {
        Utils.writeValue(FILE_TOUCHKEY_DISABLE, "1");
        Utils.writeValue(FILE_TOUCHKEY_BRIGHTNESS, "2");
        preferenceScreen.findPreference(DeviceSettings.KEY_TOUCHKEY_TIMEOUT).setEnabled(false);
      }
    }
    return true;
  }
 /**
  * Restore vibrator intensity setting from SharedPreferences. (Write to kernel.)
  *
  * @param context The context to read the SharedPreferences from
  */
 public static void restore(Context context) {
   if (!isSupported()) {
     Log.v(TAG, "No storage.rc file found, creating.");
     Utils.writeValue(
         FILE,
         "export EXTERNAL_STORAGE /storage/sdcard0" + System.getProperty("line.separator"),
         false);
     Utils.writeValue(
         FILE,
         "export SECONDARY_STORAGE /storage/sdcard1" + System.getProperty("line.separator"),
         true);
   } else {
     SharedPreferences sharedPrefs = PreferenceManager.getDefaultSharedPreferences(context);
     Log.v(
         TAG,
         "Loading preference file, Primary storage is "
             + sharedPrefs.getString(DeviceSettings.KEY_PRIMARY_STORAGE, "sdcard0"));
     Utils.writeValue(
         FILE,
         "export EXTERNAL_STORAGE "
             + sharedPrefs.getString(DeviceSettings.KEY_PRIMARY_STORAGE, "sdcard0")
             + System.getProperty("line.separator"),
         false);
     if (sharedPrefs.getString(DeviceSettings.KEY_PRIMARY_STORAGE, "sdcard0").equals("sdcard1")) {
       Utils.writeValue(
           FILE,
           "export SECONDARY_STORAGE /storage/sdcard0" + System.getProperty("line.separator"),
           true);
     } else if (sharedPrefs
         .getString(DeviceSettings.KEY_PRIMARY_STORAGE, "sdcard0")
         .equals("sdcard0")) {
       Utils.writeValue(
           FILE,
           "export SECONDARY_STORAGE /storage/sdcard1" + System.getProperty("line.separator"),
           true);
     }
   }
 }
 // @Override
 public boolean onPreferenceChange(Preference preference, Object newValue) {
   Utils.writeValue(FILE, (String) newValue);
   return true;
 }
 public static boolean isSupported() {
   return Utils.fileExists(FILE);
 }
 public boolean onPreferenceChange(Preference preference, Object newValue) {
   Utils.writeValue(FILE, ((Boolean) newValue) ? "1" : "0");
   return true;
 }