Android list of all available images

I am making an application that requires me to list all the images available on the phone’s SD card.

I tried to request the ContentResolver method, i.e.

Cursor image = getContentResolver().query(Images.Media.EXTERNAL_CONTENT_URI, new String[]{Images.Media._ID,Images.Media.DATA,Images.Media.DISPLAY_NAME}, null, null, null);

but without any results. Is there a way I can get the list, or if this is not possible, is there any possible intention (like PICK) with which I can let the user select the file and then access the path to the file that the user selected ?

Helppppp guys ...

+5
source share
2 answers

You can use gallery activity to select images, for example:

Intent intent = new Intent();
intent.setType("image/*");
intent.setAction(Intent.ACTION_GET_CONTENT);
startActivityForResult(Intent.createChooser(intent, "Select Picture"),SELECT_IMAGE);

uri

+1
//where contextObject is your activity
ContentResolver cr = contextObject.getContentResolver();

String[] columns = new String[] {
                ImageColumns._ID,
                ImageColumns.TITLE,
                ImageColumns.DATA,
                ImageColumns.MIME_TYPE,
                ImageColumns.SIZE };
cur = cr.query(MediaStore.Images.Media.EXTERNAL_CONTENT_URI,
                columns, null, null, null);

( ), . , . :

1) , USB- , .

2) , ? GLOBAL_SEARCH, , .

+8

All Articles