public void saveState(IMControlPanel controlPanel) { // save state of control panel itself StateBundle cpState = new StateBundle(mPreferences, PREFIX + ".", true); cpState.putInt("activeMethodIndex", controlPanel.getActiveMethodIndex()); cpState.commit(); // save state of all input methods for (InputMethod im : controlPanel.getInputMethods()) { StateBundle outState = new StateBundle(mPreferences, PREFIX + "." + im.getInputMethodName(), true); im.onSaveState(outState); outState.commit(); } }