I want to create settings page for my android application.In the settings page is it possible to keep the toggle button in preferences ? if yes ,kindly give me example .thanks in advance
Use the below two method to save and retreive the data in/from shared prefernce
public boolean getBooleanFromSP(Context context) {
// TODO Auto-generated method stub
SharedPreferences preferences = context.getSharedPreferences("PROJECT_NAME", android.content.Context.MODE_PRIVATE);
return preferences.getBoolean("togleButtonIsChecked", false);
}//getPWDFromSP()
public void saveBooleanInSP(Context context, boolean value){
SharedPreferences preferences = context.getSharedPreferences("PROJECT_NAME", android.content.Context.MODE_PRIVATE);
SharedPreferences.Editor editor = preferences.edit();
editor.putBoolean("togleButtonIsChecked", value);
editor.commit();
}//savePWDInSP()