Need to list the picture file of the specified directory, draw on the method of the Internet, find out that the list is all the files, so it is inconvenient to use, here also did not find a solution, through their own further research finally fix, send up to useful classmates.
In the following way can implement query implementation query SD card A subdirectory of the picture file details:
- Selection: Specifying query criteria
- String Selection = mediastore. Images. Media. DATA + "like%?" ;
- Set query Directory
- String Path="/mnt/sdcard/youpicpath";
- Define Selectionargs:
- String[] Selectionargs = {path+"%"};
- c = This . Getcontentresolver(). Query(mediastore. Images. Media. External_content_uri, null,
- Selection, Selectionargs, null);
In fact, the principle is to change the next query statement, in the query conditions to increase the MediaStore.Images.Media.DATA
field constraints, must be and the specified directory can be matched to be queried, attention
selection
and selectionArgs
parameters are used together.
How to get pictures under the specified directory in Android