public FastAdapter<Item> withSavedInstanceState(Bundle savedInstanceState,String prefix){
  if (savedInstanceState != null) {
    deselect();
    if (mPositionBasedStateManagement) {
      int[] expandedItems=savedInstanceState.getIntArray(BUNDLE_EXPANDED + prefix);
      if (expandedItems != null) {
        for (        Integer expandedItem : expandedItems) {
          expand(expandedItem);
        }
      }
      int[] selections=savedInstanceState.getIntArray(BUNDLE_SELECTIONS + prefix);
      if (selections != null) {
        for (        Integer selection : selections) {
          select(selection);
        }
      }
    }
 else {
      ArrayList<String> expandedItems=savedInstanceState.getStringArrayList(BUNDLE_EXPANDED + prefix);
      ArrayList<String> selectedItems=savedInstanceState.getStringArrayList(BUNDLE_SELECTIONS + prefix);
      Item item;
      String id;
      for (int i=0, size=getItemCount(); i < size; i++) {
        item=getItem(i);
        id=String.valueOf(item.getIdentifier());
        if (expandedItems != null && expandedItems.contains(id)) {
          expand(i);
        }
        if (selectedItems != null && selectedItems.contains(id)) {
          select(i);
        }
        AdapterUtil.restoreSubItemSelectionStatesForAlternativeStateManagement(item,selectedItems);
      }
    }
  }
  return this;
}

public FastAdapter < Item > withSavedInstanceState ( Bundle savedInstanceState , String prefix ) { if ( savedInstanceState != null ) { deselect ( ) ; if ( mPositionBasedStateManagement ) { int [ ] expandedItems = savedInstanceState . getIntArray ( BUNDLE_EXPANDED + prefix ) ; if ( expandedItems != null ) { for ( Integer expandedItem : expandedItems ) { expand ( expandedItem ) ; } } int [ ] selections = savedInstanceState . getIntArray ( BUNDLE_SELECTIONS + prefix ) ; if ( selections != null ) { for ( Integer selection : selections ) { select ( selection ) ; } } } else { ArrayList < String > expandedItems = savedInstanceState . getStringArrayList ( BUNDLE_EXPANDED + prefix ) ; ArrayList < String > selectedItems = savedInstanceState . getStringArrayList ( BUNDLE_SELECTIONS + prefix ) ; Item item ; String id ; for ( int i = 0 , size = getItemCount ( ) ; i < size ; i ++ ) { item = getItem ( i ) ; id = String . valueOf ( item . getIdentifier ( ) ) ; if ( expandedItems != null && expandedItems . contains ( id ) ) { expand ( i ) ; } if ( selectedItems != null && selectedItems . contains ( id ) ) { select ( i ) ; } AdapterUtil . restoreSubItemSelectionStatesForAlternativeStateManagement ( item , selectedItems ) ; } } } return this ; }
re - selects all elements stored in the savedinstancestate important ! call this method only after all items where added to the adapters again . otherwise it may select wrong items !
