package com.xuebiping.bolizhuzi.utils; import android.content.Context; import android.content.SharedPreferences; /** * Created by zhangbin on 2018/12/22. */ public class LongSpUtils { private final static String name = "long"; private final static int mode = Context.MODE_PRIVATE; public static void saveLong(Context context, String key, long value){ SharedPreferences sp = context.getSharedPreferences(name, mode); SharedPreferences.Editor edit = sp.edit(); edit.putLong(key, value); edit.commit(); } public static long getLong(Context context, String key) { SharedPreferences sp = context.getSharedPreferences(name, mode); return sp.getLong(key, 0); } }