Java tutorial
//package com.java2s; //License from project: Apache License import android.content.Context; import android.content.pm.ApplicationInfo; import android.content.pm.PackageInfo; import android.content.pm.PackageManager; public class Main { public static String getPackageByApkFilePath(Context context, String path) { PackageManager pm = context.getPackageManager(); String packageName = ""; PackageInfo info = pm.getPackageArchiveInfo(path, PackageManager.GET_ACTIVITIES); ApplicationInfo appInfo = null; if (info != null) { appInfo = info.applicationInfo; packageName = appInfo.packageName; // System.out.println("packageName:" + packageName); } return packageName; } }