Show photos SD android Studio

0

Good afternoon, I have a problem with the code that I expose acontinuacion, the code works perfectly at level api 19 of my cell phone and level api 26 from the emulator, the inconvenience as such is that in api level 22 and 24 that are others cell phones that I tried the code does not work

final String[] columns = {MediaStore.Images.Media.DATA, MediaStore.Images.Media._ID};
final String orderBy = MediaStore.Images.Media._ID;
Cursor imagecursor = getContentResolver().query(
        MediaStore.Images.Media.EXTERNAL_CONTENT_URI, columns, null,
        null, orderBy);
int image_column_index = imagecursor != null ? imagecursor.getColumnIndex(MediaStore.Images.Media._ID) : 0;


for (int i = 0; i < count; i++) {
    imagecursor.moveToPosition(i);
    int id = imagecursor.getInt(image_column_index);
    int dataColumnIndex = imagecursor.getColumnIndex(MediaStore.Images.Media.DATA);
    thumbnails.add(MediaStore.Images.Thumbnails.getThumbnail(
            getApplicationContext().getContentResolver(), id,
            MediaStore.Images.Thumbnails.MINI_KIND, null));
    arrPath.add(imagecursor.getString(dataColumnIndex));
    thumbnailsselection.add(false);
}
assert imagecursor != null;
imagecursor.close();

imagegrid.setAdapter(imageAdapter);

works excellent level api 19 that is my cell phone and 26 in the emulator, but in other cell phones that I have tested level api 22 and 24 does not work

    
asked by Jorge Andres Guzman Zamora 11.10.2017 в 22:42
source

0 answers