Display Android images from a special folder in the gallery view

I am trying to create a small application that displays only images from a specific folder as a gallery. I found some examples, but each of them just shows only 1 image. This example, which I will post below, was WONDERFUL help, it is almost what I want to do this, I just need to change it to display images from a specific folder, and not all folders. I spent several days trying, but I just do not add the correct code. I feel that this is a very simple thing that I also miss. Any help would be greatly appreciated!

public class AndroidCustomGallery extends Activity { private int count; private Bitmap[] thumbnails; private boolean[] thumbnailsselection; private String[] arrPath; private ImageAdapter imageAdapter; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); 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.getColumnIndex(MediaStore.Images.Media._ID); this.count = imagecursor.getCount(); this.thumbnails = new Bitmap[this.count]; this.arrPath = new String[this.count]; this.thumbnailsselection = new boolean[this.count]; for (int i = 0; i < this.count; i++) { imagecursor.moveToPosition(i); int id = imagecursor.getInt(image_column_index); int dataColumnIndex = imagecursor.getColumnIndex(MediaStore.Images.Media.DATA); thumbnails[i] = MediaStore.Images.Thumbnails.getThumbnail( getApplicationContext().getContentResolver(), id, MediaStore.Images.Thumbnails.MICRO_KIND, null); arrPath[i]= imagecursor.getString(dataColumnIndex); } GridView imagegrid = (GridView) findViewById(R.id.PhoneImageGrid); imageAdapter = new ImageAdapter(); imagegrid.setAdapter(imageAdapter); imagecursor.close(); 
+4
source share
1 answer

I thought! Below is the code for anyone who wants to do something like this.

 Cursor imagecursor = getContentResolver().query( MediaStore.Images.Media.EXTERNAL_CONTENT_URI, columns, MediaStore.Images.Media.DATA + " like ? ", new String[] {"%/yourfoldername/%"}, null); 
+13
source

All Articles