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
package com.fwupgrade.saymanss.utils;
 
import android.content.Context;
import android.content.SharedPreferences;
import android.content.SharedPreferences.Editor;
 
 
/**
 * 对sp操作进行封装
 */
public class SpUtils {
    private SharedPreferences mSp;
    private Editor mEditor;
 
    public SpUtils(Context context) {
        mSp = context.getSharedPreferences("USEE", Context.MODE_PRIVATE);
        mEditor = mSp.edit();
    }
 
    /**取出String*/
    public String getString(String key, String defValue) {
        return mSp.getString(key, defValue);
    }
 
    /**取出Int*/
    public int getInt(String key, int defValue) {
        return mSp.getInt(key, defValue);
    }
 
    /**取出Boolean*/
    public boolean getBoolean(String key, boolean defValue) {
        return mSp.getBoolean(key, defValue);
    }
 
    /**取出Boolean*/
    public float getFloat(String key, float defValue){
        return mSp.getFloat(key, defValue);
    }
 
 
    /**存入String*/
    public void putString(String key, String value) {
        mEditor.putString(key, value);
        mEditor.commit();
    }
 
    /**存入Int*/
    public void putInt(String key, int value) {
        mEditor.putInt(key, value);
        mEditor.commit();
    }
 
    /**存入Boolean*/
    public void putBoolean(String key, boolean value) {
        mEditor.putBoolean(key, value);
        mEditor.commit();
    }
}