當前位置: 首頁>>代碼示例>>Java>>正文


Java Editor.putLong方法代碼示例

本文整理匯總了Java中android.content.SharedPreferences.Editor.putLong方法的典型用法代碼示例。如果您正苦於以下問題:Java Editor.putLong方法的具體用法?Java Editor.putLong怎麽用?Java Editor.putLong使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在android.content.SharedPreferences.Editor的用法示例。


在下文中一共展示了Editor.putLong方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: put

import android.content.SharedPreferences.Editor; //導入方法依賴的package包/類
public static void put(Context context, boolean isSyn, String fileName, String key, Object
        object) {
    if (object != null) {
        Editor editor = context.getSharedPreferences(fileName, 4).edit();
        if (object instanceof String) {
            editor.putString(key, (String) object);
        } else if (object instanceof Integer) {
            editor.putInt(key, ((Integer) object).intValue());
        } else if (object instanceof Boolean) {
            editor.putBoolean(key, ((Boolean) object).booleanValue());
        } else if (object instanceof Float) {
            editor.putFloat(key, ((Float) object).floatValue());
        } else if (object instanceof Long) {
            editor.putLong(key, ((Long) object).longValue());
        } else {
            editor.putString(key, object.toString());
        }
        if (isSyn) {
            editor.commit();
        } else {
            SharedPreferencesCompat.apply(editor);
        }
    }
}
 
開發者ID:JackChan1999,項目名稱:letv,代碼行數:25,代碼來源:SharedPreferenceUtils.java

示例2: record

import android.content.SharedPreferences.Editor; //導入方法依賴的package包/類
/**
 * Record the precache event. The event is persisted in shared preferences if the native library
 * is not loaded. If library is loaded, the event will be recorded as UMA metric, and any prior
 * persisted events are recorded to UMA as well.
 * @param event the precache event.
 */
public static void record(int event) {
    SharedPreferences sharedPreferences = ContextUtils.getAppSharedPreferences();
    long persistent_metric = sharedPreferences.getLong(PREF_PERSISTENCE_METRICS, 0);
    Editor preferencesEditor = sharedPreferences.edit();

    if (LibraryLoader.isInitialized()) {
        RecordHistogram.recordEnumeratedHistogram(
                EVENTS_HISTOGRAM, Event.getBitPosition(event), Event.EVENT_END);
        for (int e : Event.getEventsFromBitMask(persistent_metric)) {
            RecordHistogram.recordEnumeratedHistogram(
                    EVENTS_HISTOGRAM, Event.getBitPosition(e), Event.EVENT_END);
        }
        preferencesEditor.remove(PREF_PERSISTENCE_METRICS);
    } else {
        // Save the metric in preferences.
        persistent_metric = Event.addEventToBitMask(persistent_metric, event);
        preferencesEditor.putLong(PREF_PERSISTENCE_METRICS, persistent_metric);
    }
    preferencesEditor.apply();
}
 
開發者ID:rkshuai,項目名稱:chromium-for-android-56-debug-video,代碼行數:27,代碼來源:PrecacheUMA.java

示例3: a

import android.content.SharedPreferences.Editor; //導入方法依賴的package包/類
private static void a(String str, Object obj) {
    Editor edit = c.edit();
    if (obj.getClass() == Boolean.class) {
        edit.putBoolean(str, ((Boolean) obj).booleanValue());
    }
    if (obj.getClass() == String.class) {
        edit.putString(str, (String) obj);
    }
    if (obj.getClass() == Integer.class) {
        edit.putInt(str, ((Integer) obj).intValue());
    }
    if (obj.getClass() == Float.class) {
        edit.putFloat(str, (float) ((Float) obj).intValue());
    }
    if (obj.getClass() == Long.class) {
        edit.putLong(str, (long) ((Long) obj).intValue());
    }
    edit.commit();
}
 
開發者ID:JackChan1999,項目名稱:letv,代碼行數:20,代碼來源:e.java

示例4: saveLatestLaunchTime

import android.content.SharedPreferences.Editor; //導入方法依賴的package包/類
public boolean saveLatestLaunchTime() {
    long t = System.currentTimeMillis();
    String date = StringUtils.timeString(t);
    String minutes = StringUtils.timeStringByMinutes(t);
    SharedPreferences sp = context.getSharedPreferences(FORCE_ALERT, 0);
    if (sp.getLong(PREF_CURRENTTIMEMILLIS, 0) != 0 && t - sp.getLong(PREF_CURRENTTIMEMILLIS, 0) < 300000) {
        return false;
    }
    Editor editor = sp.edit();
    editor.putLong(PREF_CURRENTTIMEMILLIS, t);
    editor.putString(PREF_LAUNCH_DATE, date);
    editor.putString(PREF_LAUNCH_MINUTE, minutes);
    editor.commit();
    return true;
}
 
開發者ID:JackChan1999,項目名稱:letv,代碼行數:16,代碼來源:PreferencesManager.java

示例5: writeAccessToken

import android.content.SharedPreferences.Editor; //導入方法依賴的package包/類
/**
 * 保存 Token 對象到 SharedPreferences。
 * 
 * @param context 應用程序上下文環境
 * @param token   Token 對象
 */
public static void writeAccessToken(Context context, Oauth2AccessToken token) {
    if (null == context || null == token) {
        return;
    }
    
    SharedPreferences pref = context.getSharedPreferences(PREFERENCES_NAME, Context.MODE_APPEND);
    Editor editor = pref.edit();
    editor.putString(KEY_UID, token.getUid());
    editor.putString(KEY_ACCESS_TOKEN, token.getToken());
    editor.putLong(KEY_EXPIRES_IN, token.getExpiresTime());
    editor.apply();
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:19,代碼來源:AccessTokenKeeper.java

示例6: writeAccessToken

import android.content.SharedPreferences.Editor; //導入方法依賴的package包/類
/**
 * 保存 Token 對象到 SharedPreferences。
 * 
 * @param context 應用程序上下文環境
 * @param token   Token 對象
 */
public static void writeAccessToken(Context context, Oauth2AccessToken token) {
    if (null == context || null == token) {
        return;
    }
    
    SharedPreferences pref = context.getSharedPreferences(PREFERENCES_NAME, Context.MODE_APPEND);
    Editor editor = pref.edit();
    editor.putString(KEY_UID, token.getUid());
    editor.putString(KEY_ACCESS_TOKEN, token.getToken());
    editor.putString(KEY_REFRESH_TOKEN, token.getRefreshToken());
    editor.putLong(KEY_EXPIRES_IN, token.getExpiresTime());
    editor.commit();
}
 
開發者ID:ligongzai,項目名稱:QianXun,代碼行數:20,代碼來源:AccessTokenKeeper.java

示例7: clearExtras

import android.content.SharedPreferences.Editor; //導入方法依賴的package包/類
protected static void clearExtras(Context context) {
    SharedPreferences sharedPreferences = context.getSharedPreferences("mipush_extra", 0);
    long j = sharedPreferences.getLong("wake_up", 0);
    Editor edit = sharedPreferences.edit();
    edit.clear();
    if (j > 0) {
        edit.putLong("wake_up", j);
    }
    edit.commit();
}
 
開發者ID:JackChan1999,項目名稱:boohee_v5.6,代碼行數:11,代碼來源:MiPushClient.java

示例8: putLong

import android.content.SharedPreferences.Editor; //導入方法依賴的package包/類
public static void putLong(String key, long value) {

    SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(
        BilibiliApp.getInstance());
    Editor editor = sharedPreferences.edit();
    editor.putLong(key, value);
    editor.apply();
  }
 
開發者ID:MUFCRyan,項目名稱:BilibiliClient,代碼行數:9,代碼來源:PreferenceUtil.java

示例9: f

import android.content.SharedPreferences.Editor; //導入方法依賴的package包/類
public void f(Context context) {
    SharedPreferences a = y.a(context);
    if (a != null) {
        String b = b(context);
        Editor edit = a.edit();
        edit.putString(c, b);
        edit.putLong(a, System.currentTimeMillis());
        edit.putLong(b, 0);
        edit.putLong("a_start_time", System.currentTimeMillis());
        edit.putLong("a_end_time", 0);
        edit.commit();
        bv.c("Restart session: " + b);
    }
}
 
開發者ID:JackChan1999,項目名稱:boohee_v5.6,代碼行數:15,代碼來源:aa.java

示例10: setLongValue

import android.content.SharedPreferences.Editor; //導入方法依賴的package包/類
/** 設置Key對應的long值 */
public static boolean setLongValue(Context context,String key, long value) {
	SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
	Editor editor = prefs.edit();
	editor.putLong(key, value);
	return editor.commit();
}
 
開發者ID:waylife,項目名稱:ViewDebugHelper,代碼行數:8,代碼來源:PreferencesUtil.java

示例11: setCachedExchangeRate

import android.content.SharedPreferences.Editor; //導入方法依賴的package包/類
public void setCachedExchangeRate(final ExchangeRate cachedExchangeRate) {
    final Editor edit = prefs.edit();
    edit.putString(PREFS_KEY_CACHED_EXCHANGE_CURRENCY, cachedExchangeRate.getCurrencyCode());
    edit.putLong(PREFS_KEY_CACHED_EXCHANGE_RATE_COIN, cachedExchangeRate.rate.coin.value);
    edit.putLong(PREFS_KEY_CACHED_EXCHANGE_RATE_FIAT, cachedExchangeRate.rate.fiat.value);
    edit.apply();
}
 
開發者ID:guodroid,項目名稱:okwallet,代碼行數:8,代碼來源:Configuration.java

示例12: setPreferences

import android.content.SharedPreferences.Editor; //導入方法依賴的package包/類
public static void setPreferences(Context context, String preference, String key, long value){
	if(context==null) return;
    SharedPreferences sharedPreferences = context.getSharedPreferences(preference, Context.MODE_PRIVATE);
    Editor editor = sharedPreferences.edit();
    editor.putLong(key, value);
    editor.commit();
}
 
開發者ID:fengdongfei,項目名稱:CXJPadProject,代碼行數:8,代碼來源:PreferencesUtils.java

示例13: f

import android.content.SharedPreferences.Editor; //導入方法依賴的package包/類
public void f(Context context) {
    SharedPreferences a = x.a(context);
    if (a != null) {
        String b = b(context);
        Editor edit = a.edit();
        edit.putString(c, b);
        edit.putLong(a, System.currentTimeMillis());
        edit.putLong(b, 0);
        edit.putLong("a_start_time", System.currentTimeMillis());
        edit.putLong("a_end_time", 0);
        edit.commit();
        bv.d("Restart session: " + b);
    }
}
 
開發者ID:JackChan1999,項目名稱:letv,代碼行數:15,代碼來源:z.java

示例14: putLong

import android.content.SharedPreferences.Editor; //導入方法依賴的package包/類
public void putLong(String key, long value) {
    Editor edt = sharedPreferences.edit();
    edt.putLong(key, value);
    edt.commit();
}
 
開發者ID:abook23,項目名稱:godlibrary,代碼行數:6,代碼來源:SharedPreferencesUtils.java

示例15: putLong

import android.content.SharedPreferences.Editor; //導入方法依賴的package包/類
public static void putLong(String key, long value) {
    Editor editor = sharedPreferences.edit();
    editor.putLong(key, value);
    editor.commit();
}
 
開發者ID:jiajieshen,項目名稱:AndroidDevSamples,代碼行數:6,代碼來源:SPUtil.java


注:本文中的android.content.SharedPreferences.Editor.putLong方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。