[Solved] How to resolve NullPointerException in SharedPreference? [duplicate]
[ad_1] The most likely cause is because the fragment has not yet attached to the activity. You need to call getActivity() in the fragment’s onActivityCreated() method. void onActivityCreated (Bundle savedInstanceState){ //call getActivity() here } [ad_2] solved How to resolve NullPointerException in SharedPreference? [duplicate]