android - SharedPreferences generating null pointer violation -


so stepped away working on little project couple of months , code working before breaking. getting:

"attempt invoke virtual method 'android.content.sharedpreferences android.content.context.getsharedpreferences(java.lang.string, int)' on null object reference"

public class incomingpiclistener extends intentservice {     bitmap photocapturedbitmap;     private static final string result_success = "success";     private static final string url_save_image = "http://******";     string savedtargetzenfolder;     boolean imgsaved;     ssiddbadapter ssiddb;      sharedpreferences savefolders = getsharedpreferences("folderprefs", 0);     sharedpreferences.editor editor = savefolders.edit(); 

the error comes in on "sharedpreferences savefolders = getsharedpreferences("folderprefs", 0);". again, haven't changed anything.

did change in 2 months since worked on this?

you not providing context getsharedpreferences()

sharedpreferences savefolders = getapplicationcontext().getsharedpreferences("folderprefs", 0); sharedpreferences.editor editor = savefolders.edit(); 

Comments