Skip to content

Instantly share code, notes, and snippets.

@StKotok
Last active August 29, 2015 14:18
Show Gist options
  • Save StKotok/3bc987ec9d204a683448 to your computer and use it in GitHub Desktop.
Save StKotok/3bc987ec9d204a683448 to your computer and use it in GitHub Desktop.
Read/Write preferences example
public static final String PREFERENCES_FILE = "preferences.txt";
SharedPreferences preferences = this.getSharedPreferences(PREFERENCES_FILE, MODE_PRIVATE);
String pref1Value = preferences.getString("PREF_1", ""); // This get value of PREF_1 key
SharedPreferences.Editor edit = preferences.edit();
edit.putString("key", "value"); // This put value to PREF_1 key
edit.commit(); // This write preferences to disk
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment