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

后端 未结 4 1936
醉话见心
醉话见心 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:46

    in above answer need change pInfo to pm

    like this

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

    this answer by Seth

提交回复
热议问题