Currently developing an app which loads images from SD card. In the emulator the following works fine and finds images to display. However, on the Galaxy S2 and S3 - no images are ever displayed. Any ideas?
Cursor cursor = getContentResolver().query(
MediaStore.Images.Media.EXTERNAL_CONTENT_URI,
{ MediaStore.Images.Thumbnails._ID },
null,
null,
MediaStore.Images.Media._ID
);
int columnIndex = cursor.getColumnIndexOrThrow(MediaStore.Images.Media._ID);
int size = cursor.getCount();
int imageId = 0;
for (int i = 0; i < size; i++) {
if(cursor.isClosed()) {
continue;
}
cursor.moveToPosition(i);
imageId = cursor.getInt(columnIndex);
uri = Uri.withAppendedPath(
MediaStore.Images.Thumbnails.EXTERNAL_CONTENT_URI,
Integer.toString(imageId)
);
try {
bitmap = BitmapFactory.decodeStream(getContentResolver().openInputStream(uri));
if (bitmap != null) {
newBitmap = Bitmap.createScaledBitmap(bitmap, 70, 70,true);
bitmap.recycle();
if (newBitmap != null) {
publishProgress(newBitmap);
}
}
} catch (IOException e) {}
}
cursor.close();
return null;