Weird exception: Cannot cast String to Boolean when using getBoolean

后端 未结 7 1841
温柔的废话
温柔的废话 2021-01-04 04:44

I\'m getting a very weird error. I have 2 activities. On both I\'m getting the SharedPreferences using MODE_PRIVATE (if it matters) by sp = g

7条回答
  •  萌比男神i
    2021-01-04 05:34

    The exception occurs in this Android method:

    public boolean getBoolean(String key, boolean defValue) {
        synchronized (this) {
            awaitLoadedLocked();
            Boolean v = (Boolean)mMap.get(key); // On this line
            return v != null ? v : defValue;
        }
    }
    

    The only sense I can make of this error is that your are reusing the key IntroActivity.SHOW_INTRO for a String somewhere else in your code.

提交回复
热议问题