title: How share images/videos in custom folders using ContentResolver/ or other way in Android ? Getting FileUriExposedException Exception
body: <p>I have a custom folder in the Pictures directory, like this <code>Pictures/MyFolder</code>. It has images in MyFolder. Here is how to share the images using ContentResolver on <code>MyFolder</code> only. Or is any alternative ways to share the image. It is on android 11.</p>
  <p>I queried images using the following snippets</p>
  <pre><code>  String[] projection = new String[]{
                  MediaStore.Images.Media.DATA,
                  MediaStore.Images.Media._ID,
                  MediaStore.Images.Media.BUCKET_DISPLAY_NAME,
                  MediaStore.Images.Media.DATE_TAKEN};
          Uri images = MediaStore.Images.Media.EXTERNAL_CONTENT_URI;
          final String orderBy = MediaStore.Images.Media.DATE_TAKEN;
          Cursor cur = context.getContentResolver().query(images,
                  projection, // Which
                  // columns
                  // to return
                  null, // Which rows to return (all rows)
                  null, // Selection arguments (none)
                  orderBy + &quot; DESC&quot; // Ordering
          );
  
   int bucketColumn = cur.getColumnIndex(MediaStore.Images.Media.BUCKET_DISPLAY_NAME);
              int dateColumn = cur.getColumnIndex(MediaStore.Images.Media.DATE_TAKEN);
              do {
                  bucket = cur.getString(bucketColumn);
                  if (bucket.equals(context.getString(R.string.app_name))) {
                      date = cur.getString(dateColumn);
                   
                      imagePath = listImageByFolder.get(bucket);
                      if (imagePath == null) {
                          imagePath = new ArrayList&lt;String&gt;();
                      }
                      imagePath.add(cur.getString(cur.getColumnIndex(MediaStore.Images.Media.DATA)));
  
                      Uri x = Uri.withAppendedPath(MediaStore.Images.Media.INTERNAL_CONTENT_URI, String.valueOf(cur.getString(cur.getColumnIndex(MediaStore.Images.Media.DATA))));
                      listImageByFolder.put(bucket, imagePath);
                  } ;
              } while (cur.moveToNext());
  
  
  </code></pre>
  <p>While I try to share the image, Getting <code>android.os.FileUriExposedException: file:///storage/emulated/0/Pictures/WhatsTouch/1628090801008.jpg exposed beyond app through ClipData.Item.getUri()</code> exception. Is any way to correct it or is any alternative way?</p>