public static boolean moveFile(Context context,@NonNull final File source,@NonNull final File targetDir){
  File target=new File(targetDir,source.getName());
  boolean success=source.renameTo(target);
  if (!success) {
    success=copyFile(context,source,targetDir);
    if (success) {
      success=deleteFile(context,source);
    }
  }
  return success;
}

public static boolean moveFile ( Context context , @ NonNull final File source , @ NonNull final File targetDir ) { File target = new File ( targetDir , source . getName ( ) ) ; boolean success = source . renameTo ( target ) ; if ( ! success ) { success = copyFile ( context , source , targetDir ) ; if ( success ) { success = deleteFile ( context , source ) ; } } return success ; }
move a file . the target file may even be on external sd card .
