Java tutorial
//package com.java2s; 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 String getAuthorityFromPermission(Context context, String permission) { 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; } }