I've created a new folder "sdcard/dd" by:
File album = new File(albumPath);
if (album.exists()) {
Log.d(TAG, albumPath + " already exists.");
} else {
boolean bFile = album.mkdir();
}
And Again, I create the second folder "sdcard/DD" by the same code, but, this time the album.exists() returns true, which indicates the "dd" is equals "DD".
Anyone know why the File.exists()
can NOT check the case of the folder name? Thanks!
By default Windows processes treat the file system as case-insensitive. As such they do not differentiate between files or folders based on case.
Java is a case-sensitive language, which means that the upper or lower case of letters in your Java programs matter.
Linux file system treats file and directory names as case-sensitive. FOO. txt and foo. txt will be treated as distinct files.
While Linux, and therefore also Android, normally is case-sensitive when it comes to filenames, FAT file systems, which are often used on SD cards, memory sticks etc., are case-insensitive. Therefore, Android will not differentiate between cases when it is handling files on these file systems.
So if you have two files, /sdcard/file
(on the SD card) and /data/file
(on the internal file system), you will get the following results:
new File("/sdcard/file").exists(); // true
new File("/sdcard/FILE").exists(); // true, /sdcard is a case-insensitive file system
new File("/data/file").exists(); // true
new File("/data/FILE").exists(); // false, /data is a case-sensitive file system
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With