SharedPreferencesHelper


  • 小巧玲珑
  • 功能比较俱全
  • 稳定快速
  • 简洁不再繁杂

Gradle

compile 'com.peter1303.SharedPreferencesHelper'

支持的函数:

数据类型方法
Stringsave(String tag, String str);
intsave(String tag, int value);
floatsave(String tag, float value);
booleansave(String tag, boolean value);
longsave(String tag, long value);
StringSetsave(String tag, Set value);

方法:

1.初始化 SharedPreferencesHelper

private SharedPreferencesHelper sharedPreferencesHelper = null;

默认初始化(直接使用应用的包名)

sharedPreferencesHelper = new SharedPreferencesHelper(Context context);

初始化(自定义名字)

sharedPreferencesHelper = new SharedPreferencesHelper(Context context, String name);

初始化(自定义名字和存储模式)

sharedPreferencesHelper = new SharedPreferencesHelper(Context context, int mode, String name);

2.方法

非常的简洁!

sharedPreferencesHelper.save();

3.数据

删除一个数据

sharedPreferencesHelper.delete(String tag);

清空所有的数据

sharedPreferencesHelper.clear();

4.其他

这个库支持布尔值反转存储

sharedPreferencesHelper.saveReverseBoolean(String tag, boolean defultValue);

如果您的应用需要存储应用的启动次数(调用一次记录一次)

sharedPreferencesHelper.recordLaunchTimes();

得到应用的启动次数

sharedPreferencesHelper.getLaunchTimes();

遵守条约

Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
chevron_right

Join the conversation

comment 3 comments
  • best CBD oil for pain

    It’s awesome for me to have a website, which is helpful in support of my know-how.

    thanks admin

  • buy CBD oil

    I was suggested this website by my cousin. I am not sure whether
    this post is written by him as nobody else know such detailed about my trouble.
    You’re amazing! Thanks!

Leave a comment

您的电子邮箱地址不会被公开。 必填项已用*标注

Comment
Name
Email
Website