zoukankan      html  css  js  c++  java
  • SharedPreferences用于存储数据

        /**
         * 获取登陆标识,判断是否为首次登陆
         *
         * @return
         */
        public static int loadLoginFlag(Context mContext)
        {
            SharedPreferences preference = mContext.getSharedPreferences(GConst.HAIER_FIRST_LOGIN, Context.MODE_PRIVATE);

            // android.content.SharedPreferences.getInt(String key, int defValue)
            int flag = preference.getInt(GConst.FIRST_LOGIN, GConst.IS_FIRST_LOGIN);
            return flag;
        }

        /**
         * 保存时同时修改登陆标识为非首次登陆
         */
        public static void saveNotFirst(Context mContext)
        {
            SharedPreferences preference = mContext.getSharedPreferences(GConst.HAIER_FIRST_LOGIN, Context.MODE_PRIVATE);
            Editor editor = preference.edit();

            // android.content.SharedPreferences.Editor.putInt(String key, int value)
            editor.putInt(GConst.FIRST_LOGIN, GConst.NOT_FIRST_LOGIN);
            editor.commit();
        }

  • 相关阅读:
    JS定时循环
    JS分组
    中位数 题解
    NOIP2017 D2T3 题解
    CF949E Binary Cards 题解
    友善的树形DP
    300英雄的危机(heroes)
    [北京省选集训2019]图的难题 题解
    洛谷 P1268 树的重量 题解
    洛谷 P2633 Count on a tree 题解
  • 原文地址:https://www.cnblogs.com/fengzhblog/p/2762168.html
Copyright © 2011-2022 走看看