Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Android Android Activity Lifecycle The Activity Lifecycle Saving and Retrieving Instance State

can't retrieve the data I saved in a my bundle

on the third challenge, I passed it, but passed it by cheating and want to know the appropriate way to do it. I can retrieve the data I saved, but I don't know how to assign it to mTextView without giving it a value in the onRestore method first.... Whenever I try to do something like set mUserEntry = savedInstanceState.getInt(KEY_USERENTRY) and then set mTextView to mUserEntry, it counts in wrong because I didn't declare mUserEntry. How can I assign mTextView to 10 without giving that key value a temporary name?

1 Answer

Ben Deitch
STAFF
Ben Deitch
Treehouse Teacher

Do all the work* inside the setText() method. *grabbing the value from the Bundle, and casting to a String

        mTextView.setText(savedInstanceState.getInt(KEY_USERENTRY) + "");