haijiang
2018-07-10 e48c183a0984908c14eebd9791761d13d9baca2c
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
package com.moral.screen.utils;
 
import android.content.Context;
import android.content.SharedPreferences;
import android.content.SharedPreferences.Editor;
 
import com.moral.screen.MainApp;
import com.moral.screen.activity.MapActivity;
 
public class SharedPreferencesUtil {
    private Context mContext;
    public final static String SP_LOGIN_USER_KEY = "login_user";
    public SharedPreferencesUtil(Context context) {
        this.mContext = context;
    }
 
    public void saveOrgId(int orgId){
        SharedPreferences preferences = mContext.getSharedPreferences(SP_LOGIN_USER_KEY, Context.MODE_PRIVATE);
        Editor editor = preferences.edit();
        editor.putInt("orgId",orgId);
        editor.commit();
    }
 
    public int getOrgId(){
        SharedPreferences sp = mContext.getSharedPreferences(SP_LOGIN_USER_KEY, Context.MODE_PRIVATE);
        int orgId = sp.getInt("orgId",0);
        return orgId;
    }
 
    public void exitLogin(){
        SharedPreferences preferences = mContext.getSharedPreferences(SP_LOGIN_USER_KEY, Context.MODE_PRIVATE);
        Editor editor = preferences.edit();
        editor.putInt("orgId",0);
        editor.commit();
        MainApp.theApp.orgId=0;
    }
 
 
    /**
     * 保存是否第一次登陆
     * @param flag
     */
    public void saveFirstUse(int flag) {
        SharedPreferences preferences = mContext.getSharedPreferences("firstInfo",
                Context.MODE_PRIVATE);
        Editor editor = preferences.edit();
        editor.putInt("firstUse", flag);
        editor.commit();
    }
    
    public int getFirstUse() {
        SharedPreferences preferences = mContext.getSharedPreferences("firstInfo",
                Context.MODE_PRIVATE);
        int firstUse = preferences.getInt("firstUse", 0);
        return firstUse;
    }
}