コード例 #1
0
  /** Saves the preferences which are selected on-screen by the user into shared preferences. */
  private void saveSelectedPreferences(boolean saveInList) {
    android.util.Log.i(TAG, "Saving current settings to file: " + currentSelectedConnection);

    String u = user.getText().toString();
    String h = hostname.getText().toString();

    // Only if a username and a hostname were entered, save the connection to list of connections.
    if (saveInList && !(u.equals("") || h.equals(""))) {
      saveConnections();
    }

    // Then, save the connection to a separate SharedPreferences file.
    currentConnection.setUser(u);
    currentConnection.setHostname(h);
    currentConnection.setVmname(vmname.getText().toString());
    currentConnection.setPassword(password.getText().toString());
    TextView selection = null;
    if (layoutMapSpinner != null) {
      selection = (TextView) layoutMapSpinner.getSelectedView();
    }
    if (selection != null) {
      currentConnection.setLayoutMap(selection.getText().toString());
    }
    currentConnection.saveToSharedPreferences(appContext);
  }