当前位置: 首页>>代码示例>>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;未经允许,请勿转载。