You're getting a NullPointerException
because of these lines:
SharedPreferences myFoodList;
public Editor editor=myFoodList.edit();
You cannot call the edit()
function of myFoodList
yet because it has not been initialized and is null
. You need to initialize it before you can call it, ideally in your onCreate()
function.
You can figure this out by looking at your Logcat output, specifically these lines:
Caused by: java.lang.NullPointerException
at com.example.davidson.MainMenu.<init>(MainMenu.java:26)
The logcat is telling you that your problem is on line 26 in MainMenu.java