code: public static Uri getUriForInternalMedia(Context context, File file) {
          String authority = context.getPackageName() + ".fileprovider";
          return FileProvider.getUriForFile(context, authority, file);
      }
docs: See the FileProvider example in https://developer.android.com/training/camera/photobasics