Here you can find the source of getAuthorityFromPermission(Context context, String permission)
public static final String getAuthorityFromPermission(Context context, String permission)
//package com.java2s; //License from project: Apache License import java.util.List; import android.content.Context; import android.content.pm.PackageInfo; import android.content.pm.PackageManager; import android.content.pm.ProviderInfo; import android.text.TextUtils; public class Main { public static final String getAuthorityFromPermission(Context context, String permission) {//from www .j a va 2 s . c om if (TextUtils.isEmpty(permission)) { return null; } List<PackageInfo> packs = context.getPackageManager() .getInstalledPackages(PackageManager.GET_PROVIDERS); if (packs == null) { return null; } for (PackageInfo pack : packs) { ProviderInfo[] providers = pack.providers; if (providers != null) { for (ProviderInfo provider : providers) { if (permission.equals(provider.readPermission) || permission.equals(provider.writePermission)) { return provider.authority; } } } } return null; } }