SharedPreferences nullPointerException when saving strings

后端 未结 4 723
小鲜肉
小鲜肉 2021-01-26 10:50

I am working launcher for android. At the moment I am working for address book(yes I want to include it to my launcher), but I am getting NullPointerException. Here

4条回答
  •  后悔当初
    2021-01-26 11:10

    Read this and this

    You have declared twice your SharedPreferences variable.

    Also you need to call getSharedPreference(String, int) only once, if you need to access a specific shared variable you need only pres.getString(label, default_value).

提交回复
热议问题