should the program check if a folder exists? And if not, then tell the user that there is no such folder. I found many examples explaining how to check if a file exists, but I need to know if a directory exists? All methods

boolean x = context.getExternalFilesDir("/nicknameOfUser/").exists(); Toast.makeText(context, "ExternalFilesDir : " + x, Toast.LENGTH_SHORT).show(); 

isAbsolute() , isDirectory() , isFile() , create a new path to the files - nicknameOfUser folder files - nicknameOfUser I don’t need them to be created, I just need the program to return if there is something on the specified path or not ...

How to do it? I think this is a standard question, but I can't understand ...

    1 answer 1

     String fileDir = Environment.getExternalStorageDirectory().getAbsoluteFile() + "/nicknameOfUser/"; File file = new File(fileDir); boolean x = file.exists(); 

    This method works, i.e. returns a boolean value and does not create the nicknameOfUser folder.

    • Yes! For sure! Thank you)) I almost thought it was not possible)) - Aleksey Timoshchenko
    • I came back to this method, that time I didn’t have enough time to finish everything and found out that it returns 'false' anyway ... Even when the folder is created ... Do not know why this could be so? - Aleksey Timoshchenko
    • Did not ask you immediately. Where should the folder you create be located: / data / data / package name / * storage / sdcard0 / Android / data / package name / * or storage / sdcard0 /? - qwerty123
    • Yes, yes, that's exactly the problem I just found - Aleksey Timoshchenko