public void loadState(){
  Timber.i("Loading state...");
  Scanner scanner=null;
  try {
    File save=new File(mContext.getExternalFilesDir(null),QUEUE_FILE);
    scanner=new Scanner(save);
    int currentPosition=scanner.nextInt();
    int queuePosition=scanner.nextInt();
    int queueLength=scanner.nextInt();
    long[] queueIDs=new long[queueLength];
    for (int i=0; i < queueLength; i++) {
      queueIDs[i]=scanner.nextInt();
    }
    mQueue=MediaStoreUtil.buildSongListFromIds(queueIDs,mContext);
    long[] shuffleQueueIDs;
    if (scanner.hasNextInt()) {
      shuffleQueueIDs=new long[queueLength];
      for (int i=0; i < queueLength; i++) {
        shuffleQueueIDs[i]=scanner.nextInt();
      }
      mQueueShuffled=MediaStoreUtil.buildSongListFromIds(shuffleQueueIDs,mContext);
    }
 else     if (mShuffle) {
      shuffleQueue(queuePosition);
    }
    mMediaPlayer.seekTo(currentPosition);
    setBackingQueue(queuePosition);
    mArtwork=Util.fetchFullArt(getNowPlaying());
  }
 catch (  FileNotFoundException ignored) {
    Timber.i("State does not exist. Using empty state");
  }
catch (  NoSuchElementException e) {
    Timber.i("Failed to parse previous state. Resetting...");
    mQueue.clear();
    mQueueShuffled.clear();
    setBackingQueue(0);
  }
 finally {
    if (scanner != null) {
      scanner.close();
    }
  }
}

public void loadState ( ) { Timber . i ( "Loading state..." ) ; Scanner scanner = null ; try { File save = new File ( mContext . getExternalFilesDir ( null ) , QUEUE_FILE ) ; scanner = new Scanner ( save ) ; int currentPosition = scanner . nextInt ( ) ; int queuePosition = scanner . nextInt ( ) ; int queueLength = scanner . nextInt ( ) ; long [ ] queueIDs = new long [ queueLength ] ; for ( int i = 0 ; i < queueLength ; i ++ ) { queueIDs [ i ] = scanner . nextInt ( ) ; } mQueue = MediaStoreUtil . buildSongListFromIds ( queueIDs , mContext ) ; long [ ] shuffleQueueIDs ; if ( scanner . hasNextInt ( ) ) { shuffleQueueIDs = new long [ queueLength ] ; for ( int i = 0 ; i < queueLength ; i ++ ) { shuffleQueueIDs [ i ] = scanner . nextInt ( ) ; } mQueueShuffled = MediaStoreUtil . buildSongListFromIds ( shuffleQueueIDs , mContext ) ; } else if ( mShuffle ) { shuffleQueue ( queuePosition ) ; } mMediaPlayer . seekTo ( currentPosition ) ; setBackingQueue ( queuePosition ) ; mArtwork = Util . fetchFullArt ( getNowPlaying ( ) ) ; } catch ( FileNotFoundException ignored ) { Timber . i ( "State does not exist. Using empty state" ) ; } catch ( NoSuchElementException e ) { Timber . i ( "Failed to parse previous state. Resetting..." ) ; mQueue . clear ( ) ; mQueueShuffled . clear ( ) ; setBackingQueue ( 0 ) ; } finally { if ( scanner != null ) { scanner . close ( ) ; } } }
reloads a saved state
