How do you check the directory at the directory?



  • Yuser creates a director with a name, I need to make sure that if the directory in which he creates a new director already contains that name, the function is returning. true and vice versa, if there is no such director. ♪ ♪

    I understand that you need to read all the directors' names in the body and then compare to the name that wants to create a laser, but how do you read all the names in the body?

    I started writing a function, but I can't figure out how to read the names.

    private boolean isContains(String str) {
        boolean result = false;
        String path = UtilClass.getAvatarPath(context).toString();
        File file = new File(path);
        return result;
    }
    

    Can you tell me how to do this?



  • In the end, I've developed a method for myself that checks whether the folder is located at the designated address or not.

    public static boolean isNameFree(Context context, String name) {
        final String path = Environment.getExternalStorageDirectory().getAbsoluteFile() +
                "/Android/data/com.example.android.camera2basic/files" +
                "/" + getEmail(context) + "/AvatarPackage/" + name;
    
    File file = new File(path);
    return !file.exists();
    

    }




Suggested Topics

  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2