[android-developers] libcore.io.ErrnoException: open failed: EMFILE (Too many open files)
I implemented a file cache to load small images for a long grid view. After scrolling a while, I get a lot of `libcore.io.ErrnoException: open failed: EMFILE (Too many open files)`
How do I avoid this? This is the code to read one bitmap:
File fullCacheDir = new File(Environment.getExternalStorageDirectory().toString(), cacheDir);
File file = new File(fullCacheDir.toString(), fileName);
if (!file.exists()) {
return null;
}
Bitmap bm = BitmapFactory.decodeFile(file.toString());
This is to save one bitmap:
FileOutputStream outputStream = new FileOutputStream(fileUri);
bitmap.compress(Bitmap.CompressFormat.JPEG, 100, outputStream);
outputStream.flush();
outputStream.close();
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscribe@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
0 Comments:
Post a Comment
Subscribe to Post Comments [Atom]
<< Home