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!
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