in short, incoming data data = 5592332 . I want to keep this data temporarily and rewrite it to the serial monitor when the button is pressed. but long data= mySwitch.getReceivedValue(); I can't retrieve the data because the variable is inside the if
Read about variable scope and declare your variable at the right level. When you get new data set a flag and make sure there is nothing blocking the loop