List of usage examples for android.content SharedPreferences getLong
long getLong(String key, long defValue);
From source file:Main.java
public static long getLastDispalyTime(Context context) { SharedPreferences sp = context.getSharedPreferences(DIGG_PREFERENCES, Context.MODE_PRIVATE); long value = sp.getLong("last_dig_time", -1); return value; }
From source file:Main.java
@SuppressWarnings("unchecked") public static <T> T getPref(Context _context, String prefKey, T defValue, Class<T> clazz) { final SharedPreferences pref = getDefaultSharedPreferences(_context); if (Long.class == clazz) { return (T) (Long.valueOf(pref.getLong(prefKey, (Long) defValue))); } else if (Integer.class == clazz) { return (T) (Integer.valueOf(pref.getInt(prefKey, (Integer) defValue))); } else if (defValue instanceof String) { return (T) (pref.getString(prefKey, String.valueOf(defValue))); } else if (defValue instanceof Boolean) { return (T) (Boolean.valueOf(pref.getBoolean(prefKey, (Boolean) defValue))); }/* w w w .j a va 2s . c om*/ throw new UnsupportedOperationException("Class " + clazz + " not supported"); }
From source file:Main.java
public static long fetchLongSharePref(Context context, String key) { SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(context); SharedPreferences.Editor prefsEditor = preferences.edit(); return preferences.getLong(key, -1); }
From source file:me.qisthi.cuit.helper.StorageHelper.java
public static Long getPreferenceLongValue(Activity activity, String key) { SharedPreferences sharedPreferences = activity.getPreferences(Context.MODE_PRIVATE); return sharedPreferences.getLong(key, 0); }
From source file:Main.java
/** * Gets a long value from preferences/* ww w . ja v a 2 s . co m*/ * * @param context the context * @param key the key id * @return the stored long value */ @SuppressWarnings("WeakerAccess") public static long getLong(Context context, String key) { SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(context); return sharedPreferences.getLong(key, -1L); }
From source file:com.slim.ota.settings.Settings.java
public static boolean isUpdateEnabled(Context context) { SharedPreferences prefs = context.getSharedPreferences(LAST_INTERVAL, 0); long value = prefs.getLong(LAST_INTERVAL, 0); return value != 1 ? true : false; }
From source file:com.swp.workshop.fbint.SessionStore.java
public static boolean restore(Facebook session, Context context) { SharedPreferences savedSession = context.getSharedPreferences(KEY, Context.MODE_PRIVATE); session.setAccessToken(savedSession.getString(TOKEN, null)); session.setAccessExpires(savedSession.getLong(EXPIRES, 0)); return session.isSessionValid(); }
From source file:Main.java
private static boolean confirmDownload(Context context, String stringUrl) { try {/*from w w w .j av a 2 s.c o m*/ URL url = new URL(stringUrl); HttpURLConnection urlConnection = (HttpURLConnection) url.openConnection(); long candidateDate = urlConnection.getLastModified(); final SharedPreferences prefsManager = PreferenceManager .getDefaultSharedPreferences(context.getApplicationContext()); final long savedDate = prefsManager.getLong(stringUrl, 0); urlConnection.disconnect(); if (candidateDate <= savedDate) { return false; } timeToConfirm = candidateDate; return true; } catch (Throwable localThrowable) { localThrowable.printStackTrace(); return false; } }
From source file:com.commonsware.android.qrck.SyncService.java
static boolean isSyncNeeded(Context ctxt, SharedPreferences prefs) { long now = System.currentTimeMillis(); long lastSyncTime = prefs.getLong(KEY_SYNC_TIME, 0); return (lastSyncTime == 0 || (now - lastSyncTime) >= SYNC_PERIOD || !iCanHasData(ctxt)); }
From source file:ca.tbcn.greenp.GreenParkingApp.java
public static Long getLastSyncStamp(Context context) { SharedPreferences settings = context.getSharedPreferences(PREFS_NAME, Context.MODE_PRIVATE); return settings.getLong(LAST_SYNC_PREF, 0); }