get Source Apk Path - Android android.content.pm

Android examples for android.content.pm:Apk Property

Description

get Source Apk Path

Demo Code

import android.content.Context;
import android.content.pm.ApplicationInfo;
import android.content.pm.PackageManager.NameNotFoundException;
import android.text.TextUtils;

public class Main {

  public static String getSourceApkPath(Context context, String packageName) {
    if (TextUtils.isEmpty(packageName))
      return null;

    try {//from   w  w w.j a  va 2  s .c o m
      ApplicationInfo appInfo = context.getPackageManager().getApplicationInfo(packageName, 0);
      return appInfo.sourceDir;
    } catch (NameNotFoundException e) {
      e.printStackTrace();
    }

    return null;
  }

}

Related Tutorials