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();
        }

  • 相关阅读:
    JavaScript概述
    JavaScript概述
    python语法基础
    python 网络编程
    python 日志模块
    python 异常处理
    python tricks
    记录_省赛(一)
    异或加密算法
    三目条件运算符
  • 原文地址:https://www.cnblogs.com/fengzhblog/p/2762168.html
Copyright © 2011-2022 走看看