private void toView() { preferences.reload(); // you can even reload the preferences, if you changes something characterName.setText(preferences.favoriteCharacter); dark.setChecked(preferences.dark); light.setChecked(preferences.light); int droidIndex = preferences.droid; if (droidIndex >= 0) droid.check(DROIDS.get(droidIndex)); else droid.check(-1); int shipIndex = preferences.spaceship; if (shipIndex >= 0) spaceship.check(SPACESHIPS.get(shipIndex)); else spaceship.check(-1); }
private void toPreference() { preferences.favoriteCharacter = characterName.getText().toString(); preferences.dark = dark.isChecked(); preferences.light = light.isChecked(); int checkedRadioButtonId = droid.getCheckedRadioButtonId(); if (checkedRadioButtonId >= 0) preferences.droid = DROIDS.indexOf(checkedRadioButtonId); int checkedSpaceShipId = spaceship.getCheckedRadioButtonId(); if (checkedSpaceShipId >= 0) preferences.spaceship = SPACESHIPS.indexOf(checkedSpaceShipId); preferences.apply(); }