In the above github link you are using Environment.getExternalStorageDirectory() API which is working as expected. I think you misunderstood the use of this API. This API will always return the primary external storage directory. Below explanation may help you:
First of all, What is difference between Internal Storage, External Storage (aka primary external storage) and Secondary External Storage?
Internal Storage: is storage that is not accessible by the user, except via installed apps (or by rooting their device). Example: data/data/app_packageName
Primary External Storage: In built shared storage which is "accessible by the user by plugging in a USB cable and mounting it as a drive on a host computer". Example: When we say Nexus 5 32 GB.
Secondary External Storage: Removable storage. Example: SD Card.
Now next question. How to access SD card in Lollipop?
To access SD card Android introduced new Storage Access Framework in KitKat.
Here is one answer explained it beautifully: https://stackoverflow.com/a/26765884/631803
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…