How to get all images and photos from my android device from sdcard?

I would like to get all the images / photos / wallpapers from my Android device with the saved image outline.

I implemented code for collecting images from an SD card as follows:

String[] mProjection = { MediaStore.Images.Media._ID, MediaStore.Images.Media.DATA }; mCursor = cr.query(MediaStore.Images.Media.EXTERNAL_CONTENT_URI, mProjection, null, null, MediaStore.Images.Media.DEFAULT_SORT_ORDER); 

From the code above, I can only get images from an SD card. But if the images are available in the phone’s memory, how can I get images / photos / wallpapers? If I use INTERNAL_CONTENT_URI, it does not return cover information for other images.

please, any body help me ....

+7
source share
1 answer

Try this answer, it will work:

 public static final int GALLERY_CODE = 322; Intent intent = new Intent(); intent.setType("image/*"); intent.setAction(Intent.ACTION_GET_CONTENT); startActivityForResult(Intent.createChooser( intent, "Select Picture"), GALLERY_CODE); @Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { //Assinging on corresponding import super.onActivityResult(requestCode, resultCode, data); if (requestCode == GALLERY_CODE && resultCode == RESULT_OK) { Uri selectedImageUri = data.getData(); selectedImagePath = getPath(selectedImageUri); try { //add logic for coping file } catch (Exception e) { } } } public String getPath(Uri uri) { String[] projection = { MediaStore.Images.Media.DATA }; Cursor cursor = managedQuery(uri, projection, null, null, null); int column_index = cursor .getColumnIndexOrThrow(MediaStore.Images.Media.DATA); cursor.moveToFirst(); return cursor.getString(column_index); } 
0
source

All Articles