android - BroadcastReceiver and sharedpreference -


i'm making notification using function called "reciver" extends broadcastreceiver. notification has pendingintent a.class. once notification clicked, calls a.class. within a.class, calls function in mainactivity use sharedpreference , update data. whenever reaches sharedpreference, crashes.

caused by: java.lang.nullpointerexception: attempt invoke interface method 'int android.content.sharedpreferences.getint(java.lang.string, int)' on null object reference 

any or hint appreciated.

you have initiate sharedpreferences first. that:

private preferencesmanager mpreferencesmanager; 

and in oncreate():

mpreferencesmanager = preferencesmanager.getinstance(this); 

Comments