How to check if SharedPreferences exists or not

前端 未结 4 1714
独厮守ぢ
独厮守ぢ 2020-12-13 03:54

I\'m checking in this way if the file exists, but I need to go beyond, I need to know if there is one in specific, is there any way?

File f = new File(\"/dat         


        
4条回答
  •  囚心锁ツ
    2020-12-13 04:16

    You can try this

     fun checkLoginInfo(): Boolean{
        val saveLogin = sharedPreferences.getBoolean(SAVE_LOGIN, false)
        return saveLogin
    }
    
     Checks whether the preferences contains a preference. 
     @param(SAVE_LOGIN) key The name of the preference to check.
     @param(false) default
     @return Returns true if the preference exists in the preferences, otherwise false.
    

提交回复
热议问题