I have set up a navigation drawer that needs fragments - now I need one of my fragments to have a slider switch (just a switch) that stores a Boolean value to the SharedPreferences key. Now all I need to know is how I can initialize the switch inside the Fragment.
I have tried to initialize, it in the onCreateView method of the Activity extending the Fragment, but I get an error: “Unreasonable statement”, which basically means that I can’t use it there. How should I do it? If I use the one I tried, then I get a NullPointerException. Even using a contract statement doesn’t help, as I guess I’m referencing a null object as there’s a difference way of initializing it.