Added code to store the state of each checkbox in shared preferences in order to restore correct state on restarting the app. Removed redundant code and moved setOnCheckedChangedlListener to remove a bug.