I've been bringing up the list of files in the folder as below, but I can't use the method below in Android Q(Android 10) or higher.
How do I load a list of files in the MUSIC folder using MediaStore?
public void getFileListInFolder() {
String path = Environment.getExternalStoragePublicDirectory(DIRECTORY_MUSIC);
File directory = null;
try {
directory = new File(path);
Log.i("debug","dir = " + directory);
}
catch (Exception e)
{
Log.i("debug","Uri e = " + e);
}
File[] files = directory.listFiles(new FileFilter() {
@Override
public boolean accept(File pathname) {
return pathname.isFile();
}
});
if(files != null)
{
for (int i = 0; i < files.length; i++) {
Log.i("debug", "FileName:" + files[i].getName());
}
}
}