In my application I have a SharedPreference variable that stores an int value for me. This value has to decrease as the user performs some actions, as if it were a counter. Let's say that each time the user presses a specific button this value stored in SharedPreference decreases by 1 and has to be stored again with the updated value.
What happens is that I declare this SharedPreference variable in MainActivity which is the main code however, this screen appears only once. After the user enters a value that will be requested for it and this value is entered in the SharedPreference the application will start being executed from another screen. And it is in this other screen that the value undergoes its decrease as the button is clicked. And then I caught. I do not know if I use Intent to pass the parameter, but how can I store the updated value, since this activity will not be more open.
Is there a way to use this variable in both activity? Or something like that.