Scanning and indexing files video I use the following method to scan and index video files and pass data to an array. I get video file duration, file name, files size.
Is there any better method, or do I need to improve?
public static void load_Directory_Files(File directory) {
    File[] fileList = directory.listFiles();
    if(fileList != null &amp;&amp; fileList.length &gt; 0){
        for (int i=0; i&lt;fileList.length; i++){
            if(fileList[i].isDirectory()){
                load_Directory_Files(fileList[i]);
            } else {
                String name = fileList[i].getName().toLowerCase();
                for (String extension: Constant.videoExtensions){
                    //check the type of file
                    if(name.endsWith(extension)){
                        Constant.allMediaList.add(fileList[i]);
                        String FileName = fileList[i].getName();
                        String size = Function.humanReadableByteCountSI(fileList[i].length());
                        String duration = Function.getDurationFF(fileList[i].getAbsolutePath());
                        String folderName = fileList[i].getParentFile().getName();
                        String path = fileList[i].getAbsolutePath();
                        Log.d(TAG, &quot;load_Directory_Files: &quot;+ duration + &quot;&quot; +size + &quot;&quot; + FileName);
                        Constant.allMediaListWithModel.add(new AllVideoModel(FileName, path, folderName, size, duration));
                        //when we found file
                        break;
                    }
                }
            }
        }
    }
}



public static String getDurationFF(String absolutePathThumb) {
    try{
        FFmpegMediaMetadataRetriever retriever = new FFmpegMediaMetadataRetriever();
        retriever.setDataSource(absolutePathThumb);
        String time = retriever.extractMetadata(FFmpegMediaMetadataRetriever.METADATA_KEY_DURATION);
        long timeInMillisec = Long.parseLong(time);
        return convertMillieToHMmSs(timeInMillisec);
    }catch(Exception e){
        e.printStackTrace();
        return null;
    }
}

@SuppressLint(&quot;DefaultLocale&quot;)
public static String convertMillieToHMmSs(long millie) {
    long seconds = (millie / 1000);
    long second = seconds % 60;
    long minute = (seconds / 60) % 60;
    long hour = (seconds / (60 * 60)) % 24;
    if (hour &gt; 0) {
        return String.format(&quot;%02d:%02d:%02d&quot;, hour, minute, second);
    } else {
        return String.format(&quot;%02d:%02d&quot; , minute, second);
    }
}

@SuppressLint(&quot;DefaultLocale&quot;)
public static String humanReadableByteCountSI(long bytes) {
    if (-1000 &lt; bytes &amp;&amp; bytes &lt; 1000) {
        return bytes + &quot; B&quot;;
    }
    CharacterIterator ci = new StringCharacterIterator(&quot;kMGTPE&quot;);
    while (bytes &lt;= -999_950 || bytes &gt;= 999_950) {
        bytes /= 1000;
        ci.next();
    }
    return String.format(&quot;%.1f %cB&quot;, bytes / 1000.0, ci.current());
}

The above method works but it takes time to scan and index. So how can I reduce indexing time?
public static String[] videoExtensions = {&quot;.mp4&quot;,&quot;.ts&quot;,&quot;.mkv&quot;,&quot;.mov&quot;,
        &quot;.3gp&quot;,&quot;.mv2&quot;,&quot;.m4v&quot;,&quot;.webm&quot;,&quot;.mpeg1&quot;,&quot;.mpeg2&quot;,&quot;.mts&quot;,&quot;.ogm&quot;,
        &quot;.bup&quot;, &quot;.dv&quot;,&quot;.flv&quot;,&quot;.m1v&quot;,&quot;.m2ts&quot;,&quot;.mpeg4&quot;,&quot;.vlc&quot;,&quot;.3g2&quot;,
        &quot;.avi&quot;,&quot;.mpeg&quot;,&quot;.mpg&quot;,&quot;.wmv&quot;,&quot;.asf&quot;};
Naming
The method name load_Directory_Files is a bit odd. To follow general Java naming conventions, it would be something like loadDirectoryFiles. This is called camel case.
File filtering
You can use a FileFilter to accept or discard files for the
listFiles call, no need to do it yourself:
import java.io.File;
import java.io.FileFilter;
import java.util.List;
import java.util.Arrays;

public class VideoOrDirectoryFilter implements FileFilter {

    private static final List&lt;String&gt; ALLOWED_EXTENSIONS = Arrays.asList(
        &quot;.mp4&quot;,&quot;.ts&quot;,&quot;.mkv&quot;,&quot;.mov&quot;,&quot;.3gp&quot;,&quot;.mv2&quot;,&quot;.m4v&quot;,&quot;.webm&quot;,
        &quot;.mpeg1&quot;,&quot;.mpeg2&quot;,&quot;.mts&quot;,&quot;.ogm&quot;, &quot;.bup&quot;, &quot;.dv&quot;,&quot;.flv&quot;,
        &quot;.m1v&quot;,&quot;.m2ts&quot;,&quot;.mpeg4&quot;,&quot;.vlc&quot;,&quot;.3g2&quot;,&quot;.avi&quot;,&quot;.mpeg&quot;,
        &quot;.mpg&quot;,&quot;.wmv&quot;,&quot;.asf&quot;
    );

    @Override
    public boolean accept(File file) {
        return file.isDirectory() 
            || ALLOWED_EXTENSIONS.contains(file.getName().toLowerCase());
    }
}

Null check
In loadDirectoryFiles, you can return early if the listFiles call is null:
File[] files = directory.listFiles(new VideoOrDirectoryFilter());
if (files == null) return;

Looping
Instead of the for loop with an index variable, you could use a foreach loop. That makes for cleaner code, as you directly get the object in the list. Also, you don't need to check the length of the list before looping. If it's empty, the loop will be a no-op.
for (File file : files) {
    // Do your thing with file here
}

Reimplementation
Here's a reimplementation of the loadDirectoryFiles method with the above enhancements included.
public static void loadDirectoryFiles(File directory) {
    File[] files = directory.listFiles(new VideoOrDirectoryFilter());

    if (files == null) return;

    for (File file : files) {
        if (file.isDirectory()){
            loadDirectoryFiles(file);
        } else {            
            Constant.allMediaList.add(file);
            String fileName = file.getName();
            String size = Function.humanReadableByteCountSI(file.length());
            String duration = Function.getDurationFF(file.getAbsolutePath());
            String folderName = file.getParentFile().getName();
            String path = file.getAbsolutePath();
            Log.d(TAG, &quot;load_Directory_Files: &quot;+ duration + &quot;&quot; +size + &quot;&quot; + fileName);
            Constant.allMediaListWithModel.add(new AllVideoModel(fileName, path, folderName, size, duration));
        }
    }
}