Skip to content

Commit

Permalink
Close the cursor in the comparison app
Browse files Browse the repository at this point in the history
  • Loading branch information
tyronen committed Jul 20, 2015
1 parent ea12d80 commit 842e60f
Showing 1 changed file with 17 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -336,18 +336,26 @@ public void onFinish(List<String> result) {
private void loadLocalUrls() {
Uri externalContentUri = MediaStore.Images.Media.EXTERNAL_CONTENT_URI;
String[] projection = {MediaStore.Images.Media._ID};
Cursor cursor = getContentResolver().query(externalContentUri, projection, null, null, null);

mImageUrls.clear();
Cursor cursor = null;
try {
cursor = getContentResolver().query(externalContentUri, projection, null, null, null);

int columnIndex = cursor.getColumnIndexOrThrow(MediaStore.Images.Media._ID);
mImageUrls.clear();

String imageId;
Uri imageUri;
while (cursor.moveToNext()) {
imageId = cursor.getString(columnIndex);
imageUri = Uri.withAppendedPath(MediaStore.Images.Media.EXTERNAL_CONTENT_URI, imageId);
mImageUrls.add(imageUri.toString());
int columnIndex = cursor.getColumnIndexOrThrow(MediaStore.Images.Media._ID);

String imageId;
Uri imageUri;
while (cursor.moveToNext()) {
imageId = cursor.getString(columnIndex);
imageUri = Uri.withAppendedPath(MediaStore.Images.Media.EXTERNAL_CONTENT_URI, imageId);
mImageUrls.add(imageUri.toString());
}
} finally {
if (cursor != null) {
cursor.close();
}
}
}

Expand Down

0 comments on commit 842e60f

Please sign in to comment.