I am trying to create a new folder inside sdcard using context.getExternalFilesDir() method but it doesn't work, it creates Pictures folder but it doesn't create TestFolder and txt file. My intention is to create a folder and put downloaded images from my app inside it. Unfortunately, Environment.getExternalStorageDirectory() is deprecated in API level 29 and I don't know how to fix it. As always, thank you a lot for your help!
File folder = new File(getContext().getExternalFilesDir(Environment.DIRECTORY_PICTURES), "TestFolder");
if (!folder.exists()) {
folder.mkdirs();
}
File filename = new File(folder, "test.txt");
try {
filename.createNewFile();
} catch (Exception e) {
e.printStackTrace();
}