lmw
2023-06-06 7a563b559c48b9b339784c25fc5f0adc2ab5154e
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
package com.sinata.download.utils;
 
import android.content.Context;
import android.content.SharedPreferences;
 
import com.sinata.download.DownloadLibrary;
 
/**
 * author:Created by zhaohaoting on 2019/6/27
 * email:526309416@qq.com
 * desc:
 */
public class Preferences {
    public static final String VERSION_CODE = "versionCode";
    public static final String TIPS_TIME = "tipsTime";
 
    public static SharedPreferences getSharedPreferences() {
        return DownloadLibrary.getContext().getSharedPreferences("version", Context.MODE_PRIVATE);
    }
 
    public static boolean getBoolean(String key, boolean value) {
        return getSharedPreferences().getBoolean(key, value);
    }
 
    public static void saveBoolean(String key, boolean value) {
        SharedPreferences.Editor editor = getSharedPreferences().edit();
        editor.putBoolean(key, value);
        editor.apply();
    }
 
    public static void saveLong(String key, long value) {
        SharedPreferences.Editor editor = getSharedPreferences().edit();
        editor.putLong(key, value);
        editor.apply();
    }
 
    public static long getLong(String key, long value) {
        return getSharedPreferences().getLong(key, value);
    }
 
    public static String getString(String key, String value) {
        return getSharedPreferences().getString(key, value);
    }
 
    public static void saveString(String key, String value) {
        SharedPreferences.Editor editor = getSharedPreferences().edit();
        editor.putString(key, value);
        editor.apply();
    }
 
    public static void saveInt(String key, int value) {
        SharedPreferences.Editor editor = getSharedPreferences().edit();
        editor.putInt(key, value);
        editor.apply();
    }
 
    public static int getInt(String key, int value) {
        return getSharedPreferences().getInt(key, value);
    }
 
}