I am creating an app with textView boxes. When a button is pressed the text changes using a random generator. How do I implement a favorite button so when it is pressed, a toast is created and the textView text is saved to an activity called favorites?
I would save the "textView" content as a SharedPreference
in the onClick()
method of the Button
.
When the user accesses the Favorites Activity, I would send the SharedPreference
value to the other Activity via the Extras Bundle
Depending on where you have to manage the list of stored Favorite values and how many there are, you may have to use a database instead of SharedPreference
.