Why is the value in onCreate p-.67 (key_INDEX,0)


#1

at page 67 in the book it check for the current value of the question with
if(savedInstanceState !=null) {
mCurrentIndex = savedInstanceState.getKey(KEY_INDEX,0)

I don´t get, why the second argument should be 0 - and not “mCurrentIndex” which has been set from onSavedInstanceState() - however I see that it works
regards Martin


#2

Hi Mutzon,

Here’s the documentation for the Bundle class: developer.android.com/reference/android/os/Bundle.html.

The second argument is the default value to return if there’s no mapping for the key you gave it (so for example, if you had passed something other than KEY_INDEX in as the first argument, 0 would be returned instead of mCurrentIndex).