| 注册
请输入搜索内容

热门搜索

Java Linux MySQL PHP JavaScript Hibernate jQuery Nginx
sm2011616
10年前发布

sharePreference帮助类

 import android.content.Context;  import android.content.SharedPreferences;  import android.preference.PreferenceManager;    /**   * sharePreference帮助类   *    * @author kds   */  public class SharePreferenceHelp  {  public static final String KEY_TOTAL_CALL_TIMES = "total_call_times";  public static final String KEY_TOTAL_SAVE_MONEY = "total_save_money";    public static final String KEY_CURRENT_VOICE = "current_voice";    public static final String KEY_ASSISTANT_NEW_IMAGE_VISIBLE = "assitant_new_image_visible";    /**  * 缓存省钱记录列表的key  */  public static final String KEY_CACHE_SMR_LIST = "cache_smr_list";    /**  * 省钱领先百分数key  */  public static final String KEY_FORWARD_PERCENT = "forward_percent";    /**  * 是否分享过变声功能标识key  */  public static final String KEY_HAVE_CHANGE_VOICE_SHARED = "have_change_voice_shared";    /**  * 系统通知栏显示微话图标key  */  public static final String KEY_SHOW_ONGOING_NOTIFICATION = "show_ongoing_notification";    /**  * 是否已经设置过密码  */  public static final String KEY_ALREADY_SET_PWD = "already_set_pwd";    /**  * 分享插件包名key  */  public static final String KEY_PLUGIN_PKGNAME = "plugin_pkgname";    /**  * 头像未设置标志位  */  public static final String KEY_USER_HEAD_UNSET_FLAG = "user_head_unset_flag";    // 联系人动画标识1  public static final String KEY_CONTACT_ANIMATION_FLAG1 = "contact_animation_flag1";  public static final String KEY_CONTACT_ANIMATION_FLAG1_TIME = "contact_animation_flag1_time";  // 联系人动画标识2  public static final String KEY_CONTACT_ANIMATION_FLAG2 = "contact_animation_flag2";  // 联系人详情标识  public static final String KEY_CONTACT_DETAIL_ANIMATION_FLAG = "contact_detail_animation_flag";  // 微话好友动画标识  public static final String KEY_VHUA_FRIENDS_FLAG = "vhua_friends_flag";  // T9搜索标识  public static final String KEY_T9_SEARCH_FLAG = "t9_search_flag";  // 系统拨号  public static final String KEY_SYSTEM_CALL_FLAG = "system_call_flag";  // 群聊标识  public static final String KEY_GROUP_ANIMATION_FLAG = "group_animation_flag";    public static SharePreferenceHelp INSTANCE;    private SharedPreferences preferences;    private SharePreferenceHelp()  {  }    public static synchronized SharePreferenceHelp getInstance(Context context)  {  if (INSTANCE == null)  {  INSTANCE = new SharePreferenceHelp();  INSTANCE.preferences = PreferenceManager.getDefaultSharedPreferences(context);  }  return INSTANCE;  }    /**  * 储存String值  *   * @param key  * @param value  */  public void setStringValue(String key, String value)  {  preferences.edit().putString(key, value).commit();  }    /**  * 获取String值  *   * @param key  * @return  */  public String getStringValue(String key)  {  return preferences.getString(key, "");  }    /**  * 获取String值  *   * @param key  * @return  */  public String getStringValue(String key, String devalue)  {  return preferences.getString(key, devalue);  }    /**  * 储存Boolean值  *   * @param key  * @param value  */  public void setBooleanValue(String key, Boolean value)  {  preferences.edit().putBoolean(key, value).commit();  }    /**  * 获取Boolean值  *   * @param key  * @return  */  public boolean getBooleanValue(String key)  {  return preferences.getBoolean(key, false);  }    /**  * 获取Long值  *   * @param key  * @return  */  public long getLongValue(String key)  {  return preferences.getLong(key, 0L);  }    /**  * 获取Boolean值  *   * @param key  * @return  */  public boolean getBooleanValue(String key, boolean defaultValue)  {  return preferences.getBoolean(key, defaultValue);  }    /**  * @Title: get3gValue  * @Description: 获取默认值为true的方法  * @param: @param key  * @param: @return  * @return: boolean  * @throws  */  public boolean getBoolValue(String key)  {  return preferences.getBoolean(key, true);  }    /**  * 储存int值  *   * @param key  * @param value  */  public void setIntValue(String key, int value)  {  preferences.edit().putInt(key, value).commit();  }    /**  * 获取int值  *   * @param key  * @return  */  public int getIntValue(String key)  {  return preferences.getInt(key, 0);  }    public int getIntValue(String key, int value)  {  return preferences.getInt(key, value);  }    public void remove(String name)  {  preferences.edit().remove(name).commit();  }    public void setLongValue(String key, long value)  {  preferences.edit().putLong(key, value).commit();  }    public float getFloatValue(String key, float value)  {  return preferences.getFloat(key, value);  }
 本文由用户 sm2011616 自行上传分享,仅供网友学习交流。所有权归原作者,若您的权利被侵害,请联系管理员。
 转载本站原创文章,请注明出处,并保留原始链接、图片水印。
 本站是一个以用户分享为主的开源技术平台,欢迎各类分享!
 本文地址:https://www.open-open.com/lib/view/open1419930843218.html
工具类 Android开发 移动开发