package com.lukouguoji.module_base.db.perference

import android.content.Context
import com.lukouguoji.module_base.MyApplication

object SharedPreferenceUtil {

    fun addString(key: String, value: String) {
        var context = MyApplication.context
        val editor = context.getSharedPreferences("data", Context.MODE_PRIVATE).edit()
        editor.putString(key, value)
        editor.commit()
    }

    fun getString(key: String): String {
        var context = MyApplication.context
        val editor = context.getSharedPreferences("data", Context.MODE_PRIVATE)
        return editor.getString(key, "")!!
    }

    fun remove(key: String){
        var context = MyApplication.context
        val editor = context.getSharedPreferences("data", Context.MODE_PRIVATE).edit()
        editor.remove(key)
        editor.commit()
    }

    fun addInt(key: String, value: Int) {
        var context = MyApplication.context
        val editor = context.getSharedPreferences("data", Context.MODE_PRIVATE).edit()
        editor.putInt(key, value)
        editor.commit()
    }

    fun getInt(key: String): Int {
        var context = MyApplication.context
        val editor = context.getSharedPreferences("data", Context.MODE_PRIVATE)
        return editor.getInt(key, -999)
    }
}