Example usage for android.content SharedPreferences getLong

List of usage examples for android.content SharedPreferences getLong

Introduction

In this page you can find the example usage for android.content SharedPreferences getLong.

Prototype

long getLong(String key, long defValue);

Source Link

Document

Retrieve a long value from the preferences.

Usage

From source file:Main.java

public static long getLong(Context context, String key, long defaultValue) {
    SharedPreferences settings = context.getSharedPreferences(PREFERENCE_NAME, Context.MODE_PRIVATE);
    return settings.getLong(key, defaultValue);
}

From source file:com.flowzr.budget.holo.export.flowzr.FlowzrSyncOptions.java

public static FlowzrSyncOptions fromPrefs(SharedPreferences preferences) {
    long lastSyncLocalTimestamp = preferences.getLong("PROPERTY_LAST_SYNC_TIMESTAMP", 0);
    String useCredential = preferences.getString(PROPERTY_USE_CREDENTIAL, "");
    String rootFolderId = preferences.getString(PROPERTY_ROOT_FOLDER_ID, "");
    String appVersion = preferences.getString(PROPERTY_APP_VERSION, "");
    return new FlowzrSyncOptions(useCredential, lastSyncLocalTimestamp, null, rootFolderId, appVersion);
}

From source file:Main.java

public static long ReadSharedPreferencesLong(Context context, String name, String key, long defaultvalue) {
    try {//from   w ww. j a v a2  s  .co m
        SharedPreferences userInfo = context.getSharedPreferences(name, Context.MODE_WORLD_READABLE);
        return userInfo.getLong(key, defaultvalue);
    } catch (NullPointerException e) {
        e.printStackTrace();
        return 0;
    }
}

From source file:Main.java

public static long getLong(Context context, String key) {
    SharedPreferences shared = context.getSharedPreferences(SHARED_PREFERENCE_NAME, Context.MODE_PRIVATE);
    long value = shared.getLong(key, 0L);
    return value;
}

From source file:Main.java

public static long getLong(Context context, String key) {
    SharedPreferences sharedPreferences = context.getSharedPreferences("Zelory", Context.MODE_PRIVATE);

    return sharedPreferences.getLong(key, 0);
}

From source file:Main.java

/**
 * get long preferences/*from ww w .j a  v  a2  s. c  om*/
 * 
 * @param context
 * @param key The name of the preference to retrieve
 * @param defaultValue Value to return if this preference does not exist
 * @return The preference value if it exists, or defValue. Throws ClassCastException if there is a preference with
 *         this name that is not a long
 */
public static long getLong(Context context, String key, long defaultValue) {
    SharedPreferences settings = context.getSharedPreferences(PREFERENCE_NAME, Context.MODE_PRIVATE);
    return settings.getLong(key, defaultValue);
}

From source file:Main.java

public static long getLong(Context context, String key, long defaultObject) {
    if (context == null)
        return defaultObject;
    SharedPreferences sp = context.getSharedPreferences(FILE_NAME, Context.MODE_PRIVATE);
    return sp.getLong(key, defaultObject);
}

From source file:Main.java

public static long getPreference(String key, long defaultValue, Context c) {
    SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(c);
    return preferences.getLong(key, defaultValue);
}

From source file:Main.java

private static long getLongPreference(Context context, String key) {
    long value = -1;
    SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(context);
    if (preferences != null) {
        value = preferences.getLong(key, -1);
    }//from  w ww  . j  a  v  a 2  s. co  m
    return value;
}

From source file:Main.java

/**
 * Indicates if the application must requires a new refresh token.
 * /*from   w  w  w.j  av  a 2  s . co m*/
 * @param context
 */
public static boolean doesRequireRefreshToken(Context context) {
    SharedPreferences sharedPref = PreferenceManager.getDefaultSharedPreferences(context);
    long activationTime = sharedPref.getLong(KEY_CLOUD_LOADING_TIME, DEFAULT_LOADING_TIME);
    if (activationTime == DEFAULT_LOADING_TIME) {
        return false;
    }

    long now = new Date().getTime();
    return (now - activationTime) > DEFAULT_LOADING_TIMEOUT;
}