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;
|
}
|
}
|