How can i get the apk file name and path programmatically?

后端 未结 4 1925
醉话见心
醉话见心 2020-12-18 02:55

I want to get the exact file name of a program if I already know the package name of the target apk. For instance, if I know the package name of my apk, which is com.package

4条回答
  •  轮回少年
    2020-12-18 03:23

    Well, i would like to mark Yuri as the answer but i already knew about that stuff. So I went through each and every option from PackageManager.ApplicationInfo and found .publicSourceDir

    So a complete answer with code to my question would be

    PackageManager pm = getPackageManager();
        try {
            ApplicationInfo ai = pInfo.getApplicationInfo(, 0);
            String sourceApk = ai.publicSourceDir;
        } catch (NameNotFoundException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
    

    So thanks again guys, got my brain goin once again Love StackOverflow!

提交回复
热议问题