NullPointer Check for setting pref