get Install Apk File - Android android.content.pm

Android examples for android.content.pm:Apk Install

Description

get Install Apk File

Demo Code

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 File getInstallApkFile(Context context, String packageName)
            throws NameNotFoundException {
        PackageManager pm = context.getPackageManager();
        String sourceDir = pm.getApplicationInfo(packageName, 0).sourceDir;
        File file = null;/*from   w w w .  j  av a2s .c  o  m*/
        if (sourceDir != null) {
            file = new File(sourceDir);
        }
        return file;
    }

}

Related Tutorials