0

I'm saving images to external storage, and sometimes get a "no space left on device" exception. It appears there is still space left in external storage, not sure why I'm getting this error:

Couldn't save image!: test.jpg  
java.io.FileNotFoundException: /mnt/sdcard/test/test.jpg (No space left on device)  
  at org.apache.harmony.luni.platform.OSFileSystem.openImpl(Native Method)
  at org.apache.harmony.luni.platform.OSFileSystem.open(OSFileSystem.java:152)
  at java.io.FileOutputStream.<init>(FileOutputStream.java:97)
  at java.io.FileOutputStream.<init>(FileOutputStream.java:69)
  at com.me.test.MyTest.save(MyTest.java:100) 

Any idea how this could be happening? Running on a Nexus S. When I go into System Settings -> Storage, I see under "USB Storage" the following:

Total Space: 13.31 GB
Available Space: 12.92 GB

I might be misinterpreting this as the space that's left for me?

Thanks

user291701
  • 38,411
  • 72
  • 187
  • 285
  • How are you getting the path at which to write the file? Also, does your manifest give you permission to write to the sdcard? – antlersoft Aug 31 '11 at 20:59
  • Yes, other images store there without issue (until I get the out of space exception). Using "Environment.getExternalStorageDirectory()" to get the root path to store to. I create the folder "test" in there, then store the images in that folder. – user291701 Aug 31 '11 at 21:03
  • Do you check the state of the external storage before writing? This link describes how to do that http://developer.android.com/guide/topics/data/data-storage.html#filesExternal – EpicOfChaos Aug 31 '11 at 21:21
  • Hi yeah the state of the external storage is fine, writing will go ok for a bunch of images then will hit the wall where I get denied. – user291701 Aug 31 '11 at 21:27

1 Answers1

0

This error is common in the case where there are no more inodes left in the file system.
How many files have you written to this disk?
Are your test files all very small?

KevinDTimm
  • 14,226
  • 3
  • 42
  • 60
  • 1
    Argh I think this is what I'm hitting: http://stackoverflow.com/questions/2651907/is-there-a-limit-for-the-number-of-files-in-a-directory-on-an-sd-card. My file names are actually very long (they're downloaded from the net, using their url as their filename). – user291701 Aug 31 '11 at 21:26