sharedPref.getInt: java.lang.String cannot be cast to java.lang.Integer

后端 未结 3 1245
孤街浪徒
孤街浪徒 2021-01-02 23:12

I have a preferences.xml which contains the following definition:



        
3条回答
  •  轻奢々
    轻奢々 (楼主)
    2021-01-03 00:07

    The problem is that if putInt was never called then getInt will return a null value, even if you set a default integer value.

    This seems to be a bug that was never fixed. So the solution is to call the putInt before calling getInt.

提交回复
热议问题