Skip to content

Instantly share code, notes, and snippets.

@SebastianThorn
Created September 20, 2013 18:32
Show Gist options
  • Save SebastianThorn/6641817 to your computer and use it in GitHub Desktop.
Save SebastianThorn/6641817 to your computer and use it in GitHub Desktop.
public void saveSettings(View view) {
Log.i("Debug", "@saveSettings");
EditText userEdit = (EditText) findViewById(R.id.textedit_user);
EditText serverEdit = (EditText) findViewById(R.id.textedit_server);
EditText keyEdit = (EditText) findViewById(R.id.textedit_key);
try {
SharedPreferences.Editor editor = settings.edit();
editor.putString("User", userEdit.getText().toString());
editor.putString("Server", serverEdit.getText().toString());
editor.putString("Key", keyEdit.getText().toString());
editor.commit();
} catch (NullPointerException e) {
Log.i("Debug", "Settings was empty");
e.printStackTrace();
}
Log.i("Debug", "Data saved");
fastToast(getResources().getString(R.string.flash_saved));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment