Restore activity maintaining textview value
I'm new to Android Studio, and I have a problem with my app.
I have two activities with some buttons that count click number and put the result on a text view. One of the buttons in the first activity start the second activity. In the second activity, I have to choose between 10 buttons which count click and set number in a text view, and after every click I have to return to the first activity. Then, the same process is repeated again.
I know how to change activity, but I don't know how to restore the first activity from the second, maintaining the text view value and the same when restore the second activity from the first.
How can I do it?
how to restore the first activity from the second maintaining the textview value?
Do you mean by Store Certain Value into a Variable from First Activity so that the Value can be also use and retrieve by Second Activity or Other Activity?
If this is your Question, there are few Method to do so:
- This Method simply Throw Specify Value from one screen to another
- This Method store Specify Value into a Global Variable where all activity can be access and Store Permanently only until you command to delete. Something like a 'Session' of a Website.
In your case, I would use Method 2, to store the Value in Share Preference, and whenever I want to use any Specific Value from any Activity, I would just simple call the Share Preference out. Share Preference is very useful to store Value that used for Permanent usage of the application and its Scope is covering all the Activity in your Application. You can have Great Control of it, because you can specify to Store, Rewrite, Delete the value whenever you want, in wherever you want.
I would encourage you to search more from Google and be Specific with Your Question. Hope This would Help.