If I try to write this method
public static void saveDefaultUser() {
Editor pName = PreferenceManager
.getDefaultSharedPreferences(getBaseContext())
.edit();
pName.putString("Name", name);
pName.commit();
}
doesn’t compile and I have to remove the static value,
because clearly I cannot make a static reference to the non static method.
Is there is a way to adapt this for the use in static method?
You’ll have to pass in a
Contextto your method and use that instead ofgetBaseContext().