Q:

Android: file.exists return always false in downloading and storing a file is some devices

I write a simple code to download a file to a specific directory, if it does not exists.  This is my code, which works properly in some devices and does not in some other (I know it seems ridiculous):
try {
        File direct = new File(Environment.getExternalStorageDirectory().toString() + "/abredanesh/library");
        boolean result = false;
        if(!direct.exists())
            result = direct.mkdirs();

        File myfile = new File(Environment.getExternalStorageDirectory() + "/abredanesh/library","/a.pdf");
        if (! myfile.getAbsoluteFile().exists()) {

            DownloadManager mgr = (DownloadManager) this.getSystemService(Context. DOWNLOAD_SERVICE);

            Uri downloadUri = Uri.parse(url);
            DownloadManager. Request request = new DownloadManager. Request(downloadUri);

            request.setAllowedNetworkTypes(DownloadManager. Request. NETWORK_WIFI
                    | DownloadManager. Request. NETWORK_MOBILE);
            request.setAllowedOverRoaming(false).setTitle("ابر دانش");
            request.setDescription("دانلود کتاب");
            request.setDestinationInExternalPublicDir("abredanesh/library/", "a.pdf");

            mgr.enqueue(request);
        }
    } catch (Exception e) {
        Log.e("PARSE_ERROR", e.toString());
        e.printStackTrace();
    }

And this is my permission list:
    <uses-permission android:name="android.permission. ACCESS_WIFI_STATE" />
<uses-permission android:name="android.permission. CHANGE_WIFI_MULTICAST_STATE" />
<uses-permission android:name="android.permission. CHANGE_WIFI_STATE" />
<uses-permission android:name="android.permission. WRITE_SETTINGS" />

<uses-permission android:name="android.permission. ACCESS_DOWNLOAD_MANAGER" />
<uses-permission android:name="android.permission. ACCESS_ALL_DOWNLOADS" />
<uses-permission android:name="android.permission. ACCESS_DOWNLOAD_MANAGER_ADVANCED" />

<!--  This app has permission to register and receive data message. -- >
<uses-permission android:name="android.permission. INTERNET"/>
<uses-permission android:name="android.permission. ACCESS_NETWORK_STATE"/>
<uses-permission android:name="android.permission. WRITE_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission. READ_EXTERNAL_STORAGE"/>
<!--  This app has permission to register and receive data message. -- >
<uses-permission android:name="com.google.android.c2dm.permission. RECEIVE" />
<uses-permission android:name="com.ghaleh.football.permission. C2D_MESSAGE" />

<!--  permission if the application needs to keep the processor from sleeping when a message is received. -- >
<uses-permission android:name="android.permission. WAKE_LOCK" />

My target android version is 23.  This code works fine in Samsung J2 with android 5.1 and Huawei with android 4.4.  
In the HTC desire with android 4.2 it downloads file each time beacausemyfile.getAbsoluteFile().exists() returns false. ( either myfile.exists() and myfile.canread()). 
In Nexus 5 with android 6 it shows permission error for creating folder and downloading it. 
Both Samsung and HTC have external memory and Huawei and Nexus don't.  This code creates folder and file in internal memory of Samsung and it uses external one in HTC! 
What's wrong with my code?  Do I need other permissions?  Why none of these devices work like the next one!!!  I have seen lot's of pages and questions about file.exist, however none of answers work IN ALL MY DEVICES.  
======================================================
Edit:
As @draksia recommend I tried to open the file.  I use this code to open the file:
            Intent target = new Intent(Intent. ACTION_VIEW);
        target.setDataAndType(Uri.fromFile(myfile), "application/pdf");
        target.setFlags(Intent. FLAG_ACTIVITY_NO_HISTORY);

        Intent intent = Intent.createChooser(target, "Open File");
        try {
            startActivity(intent);
        } catch (ActivityNotFoundException e) {
            // Instruct the user to install a PDF reader here, or something
        }

The Samsung and Huasei opens the file but HTC gives this error "This document cannot be opened." ( I have some apps to open pdf on HTC)

A:

Use below code to check your file path with the different versions. 
getBaseContext().getFilesDir();

In 4.0 version the path is 

"/data/data/com.androidexample.splashscreen/files".   

In 6.0 version the path is 

"/data/user/0/com.androidexample.splashscreen/files". 

A:

The problem is solved! 
As I said in the question both HTC and Samsung had external memory, however HTC used SDcard to store the file, and Samsung used internal memory.  
I thought maybe this is the problem with my device.  I restart HTC couple times but nothing happened.  Then I removed SDcard from HTC.  I shocked everything worked great using internal memory!!!  Then I put SDcard back again (I should turn off to eject or put SDcard) and it worked again!!!  Now it has both memories but it uses internal memory to store file.  
I am really confused with this storing system. 