android getSharedPreferences error: Map value without name attribute: boolean

后端 未结 3 1977
囚心锁ツ
囚心锁ツ 2020-12-07 01:42

I am trying to figure out the cause of this error it occurs on startup when i try to get the shared preferences for the app. the code is just:

settings = this.getSha

3条回答
  •  天涯浪人
    2020-12-07 02:33

    In my case

    public static String docsDownloadStatus;
    
        SharedPreferences sharedPref = context.getSharedPreferences(
                "Pref-Values", Context.MODE_PRIVATE);
        SharedPreferences.Editor editor = sharedPref.edit();
    >>>>    editor.putString(docsDownloadStatus, value);
        editor.commit();
    

    "docsDownloadStatus" is not initialized because of this whole shared pref file was corrupted. After initializing docsDownloadStatus key everything worked fine.

提交回复
热议问题