Source:
<code>public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); if (BuildConfig.HIDDEN_APP) { removeLauncherIcon(); } sharedPreferences = PreferenceManager.getDefaultSharedPreferences(this); <START> migratePreferencesIfNecessary(sharedPreferences); <END> addPreferencesFromResource(R.xml.preferences); initPreferences(); findPreference(KEY_DEVICE).setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() { @Override public boolean onPreferenceChange(Preference preference, Object newValue) { return newValue != null && !newValue.equals(""); } }); findPreference(KEY_URL).setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() { @Override public boolean onPreferenceChange(Preference preference, Object newValue) { return (newValue != null) && setServerURL(newValue.toString()); } }); findPreference(KEY_INTERVAL).setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() { @Override public boolean onPreferenceChange(Preference preference, Object newValue) { if (newValue != null) { try { int value = Integer.parseInt((String) newValue); return value > 0; } catch (NumberFormatException e) { Log.w(TAG, e); } } return false; } }); Preference.OnPreferenceChangeListener numberValidationListener = new Preference.OnPreferenceChangeListener() { @Override public boolean onPreferenceChange(Preference preference, Object newValue) { if (newValue != null) { try { int value = Integer.parseInt((String) newValue); return value >= 0; } catch (NumberFormatException e) { Log.w(TAG, e); } } return false; } }; findPreference(KEY_DISTANCE).setOnPreferenceChangeListener(numberValidationListener); findPreference(KEY_ANGLE).setOnPreferenceChangeListener(numberValidationListener); alarmManager = (AlarmManager) getSystemService(ALARM_SERVICE); alarmIntent = PendingIntent.getBroadcast(this, 0, new Intent(this, AutostartReceiver.class), 0); if (sharedPreferences.getBoolean(KEY_STATUS, false)) { startTrackingService(true, false); } }</code><technical_language>I rename migrateLegacyPreferences more clear does</technical_language>

Target:
public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); if (BuildConfig.HIDDEN_APP) { removeLauncherIcon(); } sharedPreferences = PreferenceManager.getDefaultSharedPreferences(this); migrateLegacyPreferences(sharedPreferences); addPreferencesFromResource(R.xml.preferences); initPreferences(); findPreference(KEY_DEVICE).setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() { @Override public boolean onPreferenceChange(Preference preference, Object newValue) { return newValue != null && !newValue.equals(""); } }); findPreference(KEY_URL).setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() { @Override public boolean onPreferenceChange(Preference preference, Object newValue) { return (newValue != null) && validateServerURL(newValue.toString()); } }); findPreference(KEY_INTERVAL).setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() { @Override public boolean onPreferenceChange(Preference preference, Object newValue) { if (newValue != null) { try { int value = Integer.parseInt((String) newValue); return value > 0; } catch (NumberFormatException e) { Log.w(TAG, e); } } return false; } }); Preference.OnPreferenceChangeListener numberValidationListener = new Preference.OnPreferenceChangeListener() { @Override public boolean onPreferenceChange(Preference preference, Object newValue) { if (newValue != null) { try { int value = Integer.parseInt((String) newValue); return value >= 0; } catch (NumberFormatException e) { Log.w(TAG, e); } } return false; } }; findPreference(KEY_DISTANCE).setOnPreferenceChangeListener(numberValidationListener); findPreference(KEY_ANGLE).setOnPreferenceChangeListener(numberValidationListener); alarmManager = (AlarmManager) getSystemService(ALARM_SERVICE); alarmIntent = PendingIntent.getBroadcast(this, 0, new Intent(this, AutostartReceiver.class), 0); if (sharedPreferences.getBoolean(KEY_STATUS, false)) { startTrackingService(true, false); } }