Something like this, it all looks like. When switching to settings and switching a switch there, its current value is automatically saved to preferences. When returning from the settings, we read this value from the preferences and assign it to the necessary one. We perform these operations in onResume() , since during the transition to the settings, the activation is not destroyed and the onCreate() method will not be called upon return:
public class SomeActivity extends Activity { private SharedPreferences mPreference; public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); mPreference = PreferenceManager.getDefaultSharedPreferences(this); } @Override public void onResume(){ super.onResume(); boolean isEnableJS = mPreference.getBoolean("swithJS", true); browser.getSettings().setJavaScriptEnabled(isEnabledJS); } }