this doesn't always happen so i can't understand properly what's going on: my application take and modify a picture, then save it in external storage. If i try to open in the application a new saved pictures FROM A FILE MANAGER AND NOT FROM GALLERY, it crashes when executing cursor.getCount(), in DDMS i read the error:"cursor not closed before finally" this is the piece of code where the problem is, i can post more if necessary, thank you! ps this code is taken from other answers here in stackoverflow, as you could expect i'm not an expert so please be patient with me, thanks pps i can't see immediatly images in gallery after saving it, when they appear in gallery this error desappear.
public static int getOrientation(Context context, Uri photoUri) {
/* it's on the external media. */
Cursor cursor = context.getContentResolver().query(photoUri,
new String[] { MediaStore.Images.ImageColumns.ORIENTATION }, null, null, null);
if (cursor.getCount() != 1) { //HERE IS THE PROBLEM
return -1;
}
cursor.moveToFirst();
return cursor.getInt(0);
}