Is there a limit for the number of files in a directory on an SD card?
Posted
by jamesh
on Stack Overflow
See other posts from Stack Overflow
or by jamesh
Published on 2010-04-16T09:35:45Z
Indexed on
2010/04/16
10:03 UTC
Read the original article
Hit count: 297
I have a project written for Android devices. It generates a large number of files, each day. These are all text files and images. The app uses a database to reference these files.
The app is supposed to clear up these files after a little use (perhaps after a few days), but this process may or may not be working. This is not the subject of this question.
Due to a historic accident, the organization of the files are somewhat naive: everything is in the same directory; a .hidden
directory which contains a zero byte .nomedia
file to prevent the MediaScanner indexing it.
Today, I am seeing an error reported:
java.io.IOException: Cannot create: /sdcard/.hidden/file-4200.html
at java.io.File.createNewFile(File.java:1263)
Regarding the sdcard, I see it has plenty of storage left, but counting
$ cd /Volumes/NO_NAME/.hidden
$ ls | wc -w
9058
Deleting a number of files seems to have allowed the file creation for today to proceed.
Regrettably, I did not try touch
ing a new file to try and reproduce the error on a commandline; I also deleted several hundred files rather than a handful.
However, my question is:
- are there hard limits on filesize or number of files in a directory?
- am I even on the right track here?
Nota Bene: The SD card is as-is - i.e. I haven't formatted it, so I would guess it would be a FAT-* format.
The FAT-32 format has hard limits of filesize of 2GB (well above the filesizes I am dealing with) and a limit of number of files in the root directory. I am definitely not writing files in the root directory.
© Stack Overflow or respective owner