compat/src/main/java/androidx/core/content/FileProvider.java
private static PathStrategy parsePathStrategy(Context context, String authority)
            throws IOException, XmlPullParserException {
        final SimplePathStrategy strat = new SimplePathStrategy(authority);

        final ProviderInfo info = context.getPackageManager()
                .resolveContentProvider(authority, PackageManager.GET_META_DATA);
        final XmlResourceParser in = info.loadXmlMetaData(
                context.getPackageManager(), META_DATA_FILE_PROVIDER_PATHS);
        if (in == null) {
            throw new IllegalArgumentException(
                    "Missing " + META_DATA_FILE_PROVIDER_PATHS + " meta-data");
        }

        int type;
        while ((type = in.next()) != END_DOCUMENT) {
            if (type == START_TAG) {
                final String tag = in.getName();

                final String name = in.getAttributeValue(null, ATTR_NAME);
                String path = in.getAttributeValue(null, ATTR_PATH);

                File target = null;
                if (TAG_ROOT_PATH.equals(tag)) {
                    target = DEVICE_ROOT;
                } else if (TAG_FILES_PATH.equals(tag)) {
                    target = context.getFilesDir();
                } else if (TAG_CACHE_PATH.equals(tag)) {
                    target = context.getCacheDir();
                } else if (TAG_EXTERNAL.equals(tag)) {
                    target = Environment.getExternalStorageDirectory();
                } else if (TAG_EXTERNAL_FILES.equals(tag)) {
                    File[] externalFilesDirs = ContextCompat.getExternalFilesDirs(context, null);
                    if (externalFilesDirs.length > 0) {
                        target = externalFilesDirs[0];
                    }
                } else if (TAG_EXTERNAL_CACHE.equals(tag)) {
                    File[] externalCacheDirs = ContextCompat.getExternalCacheDirs(context);
                    if (externalCacheDirs.length > 0) {
                        target = externalCacheDirs[0];
                    }
                } else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP
                        && TAG_EXTERNAL_MEDIA.equals(tag)) {
                    File[] externalMediaDirs = context.getExternalMediaDirs();
                    if (externalMediaDirs.length > 0) {
                        target = externalMediaDirs[0];
                    }
                }

                if (target != null) {
                    strat.addRoot(name, buildPath(target, path));
                }
            }
        }

        return strat;
    }
/**
     * Parse and return {@link PathStrategy} for given authority as defined in
     * {@link #META_DATA_FILE_PROVIDER_PATHS} {@code <meta-data>}.
     *
     * @see #getPathStrategy(Context, String)
     */
Parse and return  PathStrategy for given authority as defined in
#META_DATA_FILE_PROVIDER_PATHS  .


Parse and return PathStrategy for given authority as defined in #META_DATA_FILE_PROVIDER_PATHS .
private static PathStrategy parsePathStrategy(Context context, String authority)
            throws IOException, XmlPullParserException {
        final SimplePathStrategy strat = new SimplePathStrategy(authority);
        final ProviderInfo info = context.getPackageManager()
                .resolveContentProvider(authority, PackageManager.GET_META_DATA);
        final XmlResourceParser in = info.loadXmlMetaData(
                context.getPackageManager(), META_DATA_FILE_PROVIDER_PATHS);
        if (in == null) {
            throw new IllegalArgumentException(
                    "Missing " + META_DATA_FILE_PROVIDER_PATHS + " meta-data");
        }
        int type;
        while ((type = in.next()) != END_DOCUMENT) {
            if (type == START_TAG) {
                final String tag = in.getName();
                final String name = in.getAttributeValue(null, ATTR_NAME);
                String path = in.getAttributeValue(null, ATTR_PATH);
                File target = null;
                if (TAG_ROOT_PATH.equals(tag)) {
                    target = DEVICE_ROOT;
                } else if (TAG_FILES_PATH.equals(tag)) {
                    target = context.getFilesDir();
                } else if (TAG_CACHE_PATH.equals(tag)) {
                    target = context.getCacheDir();
                } else if (TAG_EXTERNAL.equals(tag)) {
                    target = Environment.getExternalStorageDirectory();
                } else if (TAG_EXTERNAL_FILES.equals(tag)) {
                    File[] externalFilesDirs = ContextCompat.getExternalFilesDirs(context, null);
                    if (externalFilesDirs.length > 0) {
                        target = externalFilesDirs[0];
                    }
                } else if (TAG_EXTERNAL_CACHE.equals(tag)) {
                    File[] externalCacheDirs = ContextCompat.getExternalCacheDirs(context);
                    if (externalCacheDirs.length > 0) {
                        target = externalCacheDirs[0];
                    }
                } else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP
                        && TAG_EXTERNAL_MEDIA.equals(tag)) {
                    File[] externalMediaDirs = context.getExternalMediaDirs();
                    if (externalMediaDirs.length > 0) {
                        target = externalMediaDirs[0];
                    }
                }
                if (target != null) {
                    strat.addRoot(name, buildPath(target, path));
                }
            }
        }
        return strat;
    }
private static PathStrategy parsePathStrategy ( Context context , String authority ) throws IOException , XmlPullParserException { final SimplePathStrategy strat = new SimplePathStrategy ( authority ) ; final ProviderInfo info = context . getPackageManager ( ) . resolveContentProvider ( authority , PackageManager . GET_META_DATA ) ; final XmlResourceParser in = info . loadXmlMetaData ( context . getPackageManager ( ) , META_DATA_FILE_PROVIDER_PATHS ) ; if ( in == null ) { throw new IllegalArgumentException ( "Missing " + META_DATA_FILE_PROVIDER_PATHS + " meta-data" ) ; } int type ; while ( ( type = in . next ( ) ) != END_DOCUMENT ) { if ( type == START_TAG ) { final String tag = in . getName ( ) ; final String name = in . getAttributeValue ( null , ATTR_NAME ) ; String path = in . getAttributeValue ( null , ATTR_PATH ) ; File target = null ; if ( TAG_ROOT_PATH . equals ( tag ) ) { target = DEVICE_ROOT ; } else if ( TAG_FILES_PATH . equals ( tag ) ) { target = context . getFilesDir ( ) ; } else if ( TAG_CACHE_PATH . equals ( tag ) ) { target = context . getCacheDir ( ) ; } else if ( TAG_EXTERNAL . equals ( tag ) ) { target = Environment . getExternalStorageDirectory ( ) ; } else if ( TAG_EXTERNAL_FILES . equals ( tag ) ) { File [ ] externalFilesDirs = ContextCompat . getExternalFilesDirs ( context , null ) ; if ( externalFilesDirs . length > 0 ) { target = externalFilesDirs [ 0 ] ; } } else if ( TAG_EXTERNAL_CACHE . equals ( tag ) ) { File [ ] externalCacheDirs = ContextCompat . getExternalCacheDirs ( context ) ; if ( externalCacheDirs . length > 0 ) { target = externalCacheDirs [ 0 ] ; } } else if ( Build . VERSION . SDK_INT >= Build . VERSION_CODES . LOLLIPOP && TAG_EXTERNAL_MEDIA . equals ( tag ) ) { File [ ] externalMediaDirs = context . getExternalMediaDirs ( ) ; if ( externalMediaDirs . length > 0 ) { target = externalMediaDirs [ 0 ] ; } } if ( target != null ) { strat . addRoot ( name , buildPath ( target , path ) ) ; } } } return strat ; }
Parse and return {@link PathStrategy} for given authority as defined in
 {@link #META_DATA_FILE_PROVIDER_PATHS} {@code <meta-data>}.
Parse and return { @link PathStrategy } for given authority as defined in { @link #META_DATA_FILE_PROVIDER_PATHS } { @code <meta - data > } .