0

I am try to get all files from download folder with this code The code give me mistake! What is the problem with this code? Is there any way to get the files? this the mistakes image

This is my code

ArrayList<File> mFiles = new ArrayList<File>();
File mDirectory;
String folderPath = "/mnt/sdcard/download";
mDirectory = new File(folderPath);
ExtensionFilenameFilter filter = new ExtensionFilenameFilter();

// Get the files in the directory
File[] files = mDirectory.listFiles(filter);
if (files != null && files.length > 0) {
    for (File f : files) {

        mFiles.add(f);
    }

    Collections.sort(mFiles, new FileComparator());
}

Is this need support libs?

tilpner
  • 4,351
  • 2
  • 22
  • 45
user5050715
  • 45
  • 10

1 Answers1

0

After declaring package of class, import classes ExtensionFilenameFilter and FileComparator.

Considering class ExtensionFilenameFilter is present in package a

and FileComparator in b.c, write:

package your_package_name;

import a.ExtensionFilenameFilter;
import b.c.FileComparator;

... //Rest of code.

Read official Java doc.

Malwinder Singh
  • 6,644
  • 14
  • 65
  • 103