get UnInstall Apk Package Name - Android android.content.pm

Android examples for android.content.pm:Apk Uninstall

Description

get UnInstall Apk Package Name

Demo Code

import android.content.Context;
import android.content.pm.ApplicationInfo;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;

public class Main {

  /**/* www. j  a  v  a2  s .  co  m*/
   * get UnInstallApkPackageName
   *
   * @param context
   *          Context
   * @param apkPath
   *          apkPath
   * @return apk PackageName
   */
  public static String getUnInstallApkPackageName(Context context, String apkPath) {
    PackageManager pm = context.getPackageManager();
    PackageInfo info = pm.getPackageArchiveInfo(apkPath, PackageManager.GET_ACTIVITIES);
    if (info != null) {
      ApplicationInfo appInfo = info.applicationInfo;
      if (appInfo != null) {
        return appInfo.packageName;
      }
    }
    return null;
  }

}

Related Tutorials