Skip to content

Instantly share code, notes, and snippets.

Andrea Cioccarelli AndreaCioccarelli

  • Italy
Block or report user

Report or block AndreaCioccarelli

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View MyPrefsFile.xml
<?xml version='1.0' encoding='utf-8' standalone='yes' ?>
<map>
<string name="name">Andrea</string>
<int name="id" value="1" />
</map>
View SharedPreferencesRead.java
public static final String Prefs = "MyPrefsFile";
SharedPreferences prefs = this.getSharedPreferences(Prefs, Context.MODE_PRIVATE);
String user = prefs.getString("name", null);
int userId = prefs.getInt("id", null);
View SharedPreferencesEdit.java
public static final String Prefs = "MyPrefsFile";
SharedPreferences.Editor editor = getSharedPreferences(Prefs, MODE_PRIVATE).edit();
editor.putString("name", "Andrea");
editor.putInt("id", 107);
editor.apply();
You can’t perform that action at this time.