I am using SWITCH (like android toggle button ) instead of normal buttons in my andorid app. The code works fine while enabling and disabling switches. But i want to store t
SharedPreferences pref = getSharedPreferences("save",MODE_PRIVATE);
unit.setChecked(pref.getBoolean("first", false));
if(isChecked) {
SharedPreferences.Editor editor = getSharedPreferences("save"MODE_PRIVATE).edit();
editor.putBoolean("first", true);
editor.apply();
unit.setChecked(true);}
else
{
SharedPreferences.Editor editor = getSharedPreferences("save",MODE_PRIVATE).edit();
editor.putBoolean("first",false);
editor.apply();
kilometer.setText("Km/h");
unit.setChecked(false);`enter code here`
}