0
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 keystrokes on a specific button this value stored in Sharedpreference decreases 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 asked for it and this value is inserted in Sharedpreference the application will start running from another screen. And it is in this other screen that the value suffers its decrease as the button is clicked. And then I stopped. I do not know if I use the Intent to pass the parameter but, as I will be able to store the updated value being that this Activity will not be more open.
Is there a way to use this variable in both Ctivity? Or something like.
You can access any Activity at Sharedpreference, I do not understand, therefore, your question.
– ramaral
Behold:
cod_final.edit().putInt("codfinal", mostrarTexto).apply();
The final variable is the one declared in the first Activity. I want her to receive another value now, but for the second Victory and still be the same value for both. When I insert this line into the second Activity the variable (cod_final) is wrong and says "cod_final cannot be resolved".– kaamis
@kaamis, you are, shall we say, somewhat when "lost," read that, and maybe you understand.
– Fernando Leal