Listing 3.7 Checking bundle in onCreate(…)


#1

As per the book,
"
if (savedInstanceState != null) {
mCurrentIndex = savedInstanceState.getInt(KEY_INDEX, 0);
}

    updateQuestion();
}

"
If I implement as such in my code, the app is not remembering the data saved between rotations (which is what expected).
I found that if I put the code snippet just before “super.onCreate(savedInstanceState);” then it is working as expected.

This is what I currently have in my code.

"
@Override
protected void onCreate(Bundle savedInstanceState) {
if(savedInstanceState != null)
{
mCurrentIndex = savedInstanceState.getInt(KEY_INDEX,0);
}

    super.onCreate(savedInstanceState);
   ------

"
Not sure whether there is a typo in the book or not ?


#2

mine worked fine the way it was in the book. Are you sure you wrote everything down correctly from Listing 3.6?