Created
July 9, 2016 19:48
-
-
Save Sparker0i/4d3f4bfe3d5f86f98d83bdf1784ef78c to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import android.app.Activity; | |
import android.content.SharedPreferences; | |
public class CityPreference { | |
SharedPreferences prefs; | |
public CityPreference(Activity activity){ | |
prefs = activity.getPreferences(Activity.MODE_PRIVATE); | |
} | |
// If the user has not chosen a city yet, return | |
// Sydney as the default city | |
String getCity(){ | |
return prefs.getString("city", "Sydney"); | |
} | |
void setCity(String city) { | |
prefs.edit().putString("city", city).commit(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment