Code example for Fragment

Methods: onSaveInstanceState

0
     * the system to restart the Fragment later on. 
     */ 
    @Override 
    public void onSaveInstanceState(Bundle bundle) {
        // Always call the super method first 
        super.onSaveInstanceState(bundle);
         
        // Puts the current URL for the picture being shown into the saved state 
        bundle.putString(PHOTO_URL_KEY, mURLString);
    } 
 
    /** 
     * Sets the photo for this Fragment, by storing a URL that points to a picture 
     * @param urlString A String representation of the URL pointing to the picture 
     */ 
    public void setPhoto(String urlString) {
        mURLString = urlString;
    } 
}