'How to tell if a preference was activated or deactivated when clicked in android studio (java)

I am simply trying to know the syntax for checking if the preference from a switchPreferenceCompat was turned 'on' or 'off' when it was clicked. I have the onPreferenceClick() set up but inside it i want to say if () do this, else do that. Any ideas? (the preference saves its 'on' or 'off' status, so its not like they can only turn off when they are clicked once, etc.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source