Android examples for android.content.pm:Apk Property
get Apk Path and return a Map
import android.content.Context; import android.content.pm.ApplicationInfo; import android.content.pm.PackageInfo; import android.content.pm.PackageManager; import android.content.pm.PackageManager; import java.io.File; import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; public class Main{ public static Map<String, PackageInfo> getApkPathMap(Context context) { Map<String, PackageInfo> apkMap = new HashMap<String, PackageInfo>(); List<PackageInfo> packageList = getAllPackages(context); if (packageList != null && packageList.size() > 0) { for (PackageInfo pkg : packageList) { apkMap.put(pkg.packageName, pkg); }/*ww w. ja v a 2s .co m*/ } return apkMap; } public static List<PackageInfo> getAllPackages(Context context) { List<PackageInfo> packageList = new ArrayList<PackageInfo>(); PackageManager pm = context.getPackageManager(); packageList = pm.getInstalledPackages(0); return packageList; } }