Shared preferences

Let's launch the FourGoats app and register a new user using the register option. Once created, login using the credentials, I have used username as test and test as its password, as shown following:

Shared preferences

Shared Preferences are created using the SharedPreferences class. Below is the piece of code used to store the username and password in the credentials.xml file:

public void saveCredentials(String paramString1, String paramString2) { SharedPreferences.Editor localEditor = getSharedPreferences("credentials", 1).edit(); localEditor.putString("username", paramString1); localEditor.putString("password", paramString2); localEditor.putBoolean("remember", ...

Get Hacking Android now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.