As you described, when user hit next button, the radio buttons are cleared, if you don't save the user's selection, of course the user cannot check his previous answers.
So I think you need to create a HashMap
, which uses the questionIndex
as the key, and answer
as the value, to store the user's selections. Each time user hits next button, just put user's selection into hashmap with question's ID. When user hits previous button, just get the previous question's index and get the answer from the hashmap, and make the corresponding radio button selected.