Here after downloading a file in chromebrowser in mobile I'm trying to check that filename is present in Internal shared storage downloads folder in mobile but it is showing null exception.

How to give proper downloads path in android mobile device please help anyone I'm struggling?

From last 3 days I am using REDMI Y2 mobile I have Filemanager in that default directory, Downloads is there.

       public static Boolean isFileDownloaded(String fileName) {
        boolean flag = false;
        try {
       // String dirPath = "Downloads//storage//emulated//0//Download//"+fileName; 
          String dirPath = "/storage/emulated/0/Download/"+fileName;
        File dir = new File(dirPath);
        File[] files = dir.listFiles();
        if (files.length == 0 || files == null) {
            System.out.println("The directory is empty");
            flag = false;
        } else {
            for (File listFile : files) {
                if (listFile.getName().contains(fileName)) {
                    System.out.println(fileName + " is present");
                flag = true;
        catch(Exception e) {
        return flag;

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.