get Apk Path within Context - Android android.content.pm

Android examples for android.content.pm:Apk Property

Description

get Apk Path within Context

Demo Code

import java.util.ArrayList;
import java.util.List;

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

public class Main {

  public static List<String> getApkPath(Context context) {
    List<String> apkPathList = new ArrayList<String>();
    PackageManager pm = context.getPackageManager();
    List<PackageInfo> pkginfolist = pm.getInstalledPackages(0);
    for (int i = 0; i < pkginfolist.size(); i++) {
      String sourceDir = pkginfolist.get(i).applicationInfo.sourceDir;
      apkPathList.add(sourceDir);/*from ww  w. ja  v a2s  .  c o  m*/
    }
    return apkPathList;
  }

}

Related Tutorials