package com.renitha.Pref;

import android.content.Context;
import android.content.SharedPreferences;

/**
 * Created by TEJ on 28-Apr-16.
 */
public class Pref {
    private static final String PREF_NAME   = "RENITHA";
    private static final String LOGIN_ID    = "LOGIN_ID";
    private static final String LOGIN_TYPE  = "LOGIN_TYPE";
    private static final String IS_LOGIN    = "IS_LOGINED";
    private static final String TOKEN_ID    = "TOKEN_ID";
    private static final String TICKET_ID    = "TICKET_ID";

    private SharedPreferences sharedPreferences;
    private SharedPreferences.Editor editor;
    private static Pref instance;

    private Pref(Context context) {
        sharedPreferences = context.getSharedPreferences(PREF_NAME, 0);
        editor = sharedPreferences.edit();
    }

    public static final Pref getInstance(Context context) {
        if (instance == null) {
            instance = new Pref(context);
        }
        return instance;
    }
    public void setIsLogin(boolean isLogin) {
        editor.putBoolean(IS_LOGIN, isLogin).commit();
    }

    public boolean getIsLogin() {
        return sharedPreferences.getBoolean(IS_LOGIN, false);
    }

    public void setLoginId(String id) {
        editor.putString(LOGIN_ID, id).commit();
    }
    public String getLoginId() {
        return sharedPreferences.getString(LOGIN_ID, "");
    }

    public void setLoginType(String id) {
        editor.putString(LOGIN_TYPE, id).commit();
    }
    public String getLoginType() {
        return sharedPreferences.getString(LOGIN_TYPE, "");
    }

    public void setTokenIdd(String id) {
        editor.putString(TOKEN_ID, id).commit();
    }
    public String getTokenIdd()
    {
        return sharedPreferences.getString(TOKEN_ID, "");
    }

    public void setTICKET_ID(String id) {
        editor.putString(TICKET_ID, id).commit();
    }
    public String getTICKET_ID()
    {
        return sharedPreferences.getString(TICKET_ID, "");
    }

}
