public static boolean deleteFilesInFolder(Context context,@NonNull final File folder){
  boolean totalSuccess=true;
  String[] children=folder.list();
  if (children != null) {
    for (    String child : children) {
      File file=new File(folder,child);
      if (!file.isDirectory()) {
        boolean success=deleteFile(context,file);
        if (!success) {
          Log.w(TAG,"Failed to delete file" + child);
          totalSuccess=false;
        }
      }
    }
  }
  return totalSuccess;
}

public static boolean deleteFilesInFolder ( Context context , @ NonNull final File folder ) { boolean totalSuccess = true ; String [ ] children = folder . list ( ) ; if ( children != null ) { for ( String child : children ) { File file = new File ( folder , child ) ; if ( ! file . isDirectory ( ) ) { boolean success = deleteFile ( context , file ) ; if ( ! success ) { Log . w ( TAG , "Failed to delete file" + child ) ; totalSuccess = false ; } } } } return totalSuccess ; }
delete all files in a folder .
