public static void moveFolder(final File sourceLocation,final File targetLocation) throws IOException {
  Log.i(TAG,"Moving folder content " + sourceLocation + " to "+ targetLocation);
  if (sourceLocation.isDirectory()) {
    if (!targetLocation.exists() && !targetLocation.mkdirs()) {
      throw new IOException("Cannot create dir " + targetLocation.getAbsolutePath());
    }
    final String[] children=sourceLocation.list();
    for (int i=0; i < children.length; i++) {
      moveFolder(new File(sourceLocation,children[i]),new File(targetLocation,children[i]));
    }
  }
 else {
    final File directory=targetLocation.getParentFile();
    if (directory != null && !directory.exists() && !directory.mkdirs()) {
      throw new IOException("Cannot create dir " + directory.getAbsolutePath());
    }
    final boolean good=sourceLocation.renameTo(targetLocation);
    if (!good) {
      Log.e(TAG,"Error moving " + sourceLocation + " to "+ targetLocation);
    }
  }
}

public static void moveFolder ( final File sourceLocation , final File targetLocation ) throws IOException { Log . i ( TAG , "Moving folder content " + sourceLocation + " to " + targetLocation ) ; if ( sourceLocation . isDirectory ( ) ) { if ( ! targetLocation . exists ( ) && ! targetLocation . mkdirs ( ) ) { throw new IOException ( "Cannot create dir " + targetLocation . getAbsolutePath ( ) ) ; } final String [ ] children = sourceLocation . list ( ) ; for ( int i = 0 ; i < children . length ; i ++ ) { moveFolder ( new File ( sourceLocation , children [ i ] ) , new File ( targetLocation , children [ i ] ) ) ; } } else { final File directory = targetLocation . getParentFile ( ) ; if ( directory != null && ! directory . exists ( ) && ! directory . mkdirs ( ) ) { throw new IOException ( "Cannot create dir " + directory . getAbsolutePath ( ) ) ; } final boolean good = sourceLocation . renameTo ( targetLocation ) ; if ( ! good ) { Log . e ( TAG , "Error moving " + sourceLocation + " to " + targetLocation ) ; } } }
moves folder from on location to another
