Back to project page checkin.
The source code is released under:
# License Copyright ? 2014 Sam Whited Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the ?Software??), to deal ...
If you think the Android project checkin listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
package com.samwhited.checkin.util; import android.content.Context; import android.preference.PreferenceManager; //from w ww. j a va 2 s .c o m /** * A utility class for setting preferences without remembering a lot of keys everywhere. */ public final class CheckInPreferences { private static final String SERVER_PREF = "pref_server"; private static final String APIKEY_PREF = "pref_api_key"; private static final String LAST_CHECKIN = "last_checkin"; public static String getServerPref(final Context context) { return getStringPreference(context, SERVER_PREF, ""); } public static String getApikeyPref(final Context context) { return getStringPreference(context, APIKEY_PREF, ""); } public static long getLastCheckin(final Context context) { return getLongPreference(context, LAST_CHECKIN, 0); } public static void setLastCheckin(final Context context, final long time) { setLongPreference(context, LAST_CHECKIN, time); } private static String getStringPreference(final Context context, final String key, final String defaultValue) { return PreferenceManager.getDefaultSharedPreferences(context).getString(key, defaultValue); } private static long getLongPreference(final Context context, final String key, final long defaultValue) { return PreferenceManager.getDefaultSharedPreferences(context).getLong(key, defaultValue); } private static void setLongPreference(final Context context, final String key, final long value) { PreferenceManager.getDefaultSharedPreferences(context).edit().putLong(key, value).commit(); } }