Why does the Android system throw this Exception?
05-18 12:33:44.169 W/System.err( 8230): java.io.IOException: Is a directory
05-18 12:33:44.169 W/System.err( 8230): at org.apache.harmony.luni.platform.OSFileSystem.read(Native Method)
05-18 12:33:44.169 W/System.err( 8230): at dalvik.system.BlockGuard$WrappedFileSystem.read(BlockGuard.java:165)
05-18 12:33:44.169 W/System.err( 8230): at java.io.FileInputStream.read(FileInputStream.java:290)
05-18 12:33:44.169 W/System.err( 8230): at java.io.BufferedInputStream.fillbuf(BufferedInputStream.java:166)
05-18 12:33:44.169 W/System.err( 8230): at java.io.BufferedInputStream.read(BufferedInputStream.java:324)
05-18 12:33:44.169 W/System.err( 8230): at android.graphics.BitmapFactory.nativeDecodeStream(Native Method)
05-18 12:33:44.169 W/System.err( 8230): at android.graphics.BitmapFactory.decodeStream(BitmapFactory.java:573)
05-18 12:33:44.169 W/System.err( 8230): at android.graphics.BitmapFactory.decodeFile(BitmapFactory.java:384)
05-18 12:33:44.169 W/System.err( 8230): at android.graphics.BitmapFactory.decodeFile(BitmapFactory.java:412)
05-18 12:33:44.169 W/System.err( 8230): at dalvik.system.NativeStart.run(Native Method)
05-18 12:33:44.169 D/skia ( 8230): ---- read threw an exception
I am loading the images into memory like this:
return BitmapFactory.DecodeFile(fullPathToImage);
This is not causing failing problems, but it does cause unnecessary delays in the loading.
The image is stored on the Environment.ExternalStorageDirectory.AbsolutePath. The path is the full path including the image filename and extension. The image does load properly, so why does it do this?
I saw this SO: java.io.IOException: Is a directory Android, but this seems to be related to drawable resources, which I am not using.
I’d be curious to see if you still get the error if you wrapped your DecodeFile call in a check to see whether the file system thinks it’s a directory:
One other possibly useful thought. If you’re dealing with very large images and you don’t need them to be full resolution, you could possibly improve performance by reducing their size: