Skip to content

Instantly share code, notes, and snippets.

@RichLogan
Created November 6, 2014 13:28
Show Gist options
  • Save RichLogan/5909bc2756b442bf5d93 to your computer and use it in GitHub Desktop.
Save RichLogan/5909bc2756b442bf5d93 to your computer and use it in GitHub Desktop.
Get logged in Android user
// To Get
SharedPreferences account = getSharedPreferences("account", 0);
String username = account.getString("username", null);
//To Set
SharedPreferences account = getSharedPreferences("account", 0);
SharedPreferences.Editor edit = account.edit();
edit.putString("username", InsertUsernameHere);
edit.commit();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment