Logout clear SharedPreferences

前端 未结 6 2092
清歌不尽
清歌不尽 2021-02-07 02:43

I have a login page that saves username and password to SharedPreferences. I have another Activity class that includes a logo

6条回答
  •  孤城傲影
    2021-02-07 03:02

    In Kotlin you can use this code to clear the sharedpreference data

    private val sharedPref = "sharedpreference"
    
    val sharedPreferences: SharedPreferences = context.getSharedPreferences(sharedPref, Context.MODE_PRIVATE)
                val editor = sharedPreferences.edit()
                editor.clear()
                editor.apply()
    

提交回复
热议问题