When you get a picture thumbnail, get the cursor and do the related actions.
cursor cursor = context.getcontentresolver (). Query (MediaStore.Images.Thumbnails.EXTERNAL_CONTENT_URI, Thumbnail_store_image, + "=?" , New String[]{id + ""}, null);
The following exception occurred:
07-06 09:40:14.945 26649-26671/com.xxx.xxx e/contentresolver:cursor leak detected, query params:uri=content://media/external/images/thumbnails, projection=[ljava.lang.string;@4214bca8, selection=image_id =?, Selectionargs=[ljava.lang.string;@421d05f8, Sortorder=null07-06 09:40:14.945 26649-26671/com.xxx.xxx e/androidruntime:fatal exception:thread-1075java.lang.IllegalStateException:Process26649 exceeded cursor Quota 100, would kill it at Android.os.Parcel.readException (P Arcel.java:1433) at Android.database.DatabaseUtils.readExceptionFr Omparcel (Databaseutils.java:188) at Android.database.DatabaseUtils.readExceptionFr Omparcel (Databaseutils.java:140) at Android.content.ContentProviderProxy.query (Con Tentprovidernative.java:366) at Android.content.ContentResolver.query (contentr Esolver.java:411) at Android.content.ContentResolver.query (contentr Esolver.java:354) at Com.xxx.xxx.utils.localalbum.common.LocalImage Helper.getthumbnail (Localimagehelper.java:179) at Com.xxx.xxx.utils.localalbum.common.LocalImage Helper.initimage (Localimagehelper.java:139) at Com.xxx.xxx.utils.localalbum.common.LocalImage helper$1.run (localimagehelper.java:92) at Java.lang.Thread.run (Thread.java:856)
This is caused by a problem with the cursor not being closed. Close the cursor inside the finnally.
cursor cursor = context.getcontentresolver (). Query (MediaStore.Images.Thumbnails.EXTERNAL_CONTENT_URI, Thumbnail_store_image, + "=?" , New String[]{id + ""}, null); Try { ... } finally { if(null ! = cursor) { cursor.close (); } }
However, if Context.managedquery () is used, if the Cursor.close () method is used above android4.0, the following exception is reported:
E/androidruntime (31184): caused by:android.database.StaleDataException:Attempted to access a cursor after it has been CL osed.
In Android 4.0 and above, the cursor is automatically closed and does not need to be closed by the user.
Workaround:
if (VERSION. Sdk_int <) { cursor.close ();}
Context.managedquery () and context.getcontentresolver () get cursor close considerations