本文整理汇总了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);
}
}
}
示例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();
}
示例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();
}
示例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;
}
示例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();
}
示例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();
}
示例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();
}
示例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();
}
示例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);
}
}
示例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();
}
示例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();
}
示例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();
}
示例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);
}
}
示例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();
}
示例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();
}