package com.makeeasy.dailyinterest;

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

public class Utils {
    public static String userID = "";
    public static String userName = "";
    public static String userEmail = "";
    public static String userDP = "";
    public static String userPhone = "";
    public static String deposit = "";
    public static String withdraw = "";
    public static String Link = "";
    public static String Version = "";
    public static String CashFreeId = "";
    public static String CashFreeUpi = "";
    public static String Rate = "5";

    public static void saveTag(Context ctx, String tag, Object value) {
        SharedPreferences preferences = ctx.getSharedPreferences(ctx.getPackageName(),Context.MODE_PRIVATE);
        SharedPreferences.Editor editor = preferences.edit();
        if(value.getClass()==String.class){
            editor.putString(tag, (String) value);
        } else if(value.getClass()==Integer.class){
            editor.putInt(tag, (Integer) value);
        } else if(value.getClass()==Boolean.class){
            editor.putBoolean(tag, (Boolean) value);
        }
        editor.apply();
    }

    public static String getString(Context ctx,String tag) {
        SharedPreferences preferences = ctx.getSharedPreferences(ctx.getPackageName(),Context.MODE_PRIVATE);
        if (preferences != null && preferences.contains(tag)) {
            return preferences.getString(tag, "");
        } else {
            return "";
        }
    }

    public static int getInt(Context ctx,String tag) {
        SharedPreferences preferences = ctx.getSharedPreferences(ctx.getPackageName(),Context.MODE_PRIVATE);
        if (preferences != null && preferences.contains(tag)) {
            return preferences.getInt(tag, 0);
        }
        return 0;
    }

    public static boolean getBoolean(Context ctx,String tag) {
        SharedPreferences preferences = ctx.getSharedPreferences(ctx.getPackageName(),Context.MODE_PRIVATE);
        if (preferences != null && preferences.contains(tag)) {
            return preferences.getBoolean(tag, false);
        }
        return false;
    }
    
}
