how to find my android application's storing path of apk file

前端 未结 3 1016
清酒与你
清酒与你 2020-12-22 01:09

I want to make an application that could send itself (apk file) by bluetooth. but i have trouble with finding the apk file path. i tried this code:

final Pac         


        
3条回答
  •  慢半拍i
    慢半拍i (楼主)
    2020-12-22 02:08

    List PackageManager.getInstalledApplications() // will give you a list of the installed applications, and 
    ApplicationInfo.sourceDir  //is the path to the .apk file.
    
    PackageManager pm = getPackageManager();
    
    for (ApplicationInfo app : pm.getInstalledApplications(0)) {
      Log.d("PackageList", "package: " + app.packageName + ", sourceDir: " + app.sourceDir);
    }
    

    Outputs something like this:

    package: com.tmobile.themechooser, sourceDir: /system/app/ThemeChooser.apk
    package: com.tmobile.thememanager, sourceDir: /system/app/ThemeManager.apk
    package: com.touchtype.swiftkey, sourceDir: /data/app/com.touchtype.swiftkey-1.apk
    package: com.twitter.android, sourceDir: /data/app/com.twitter.android-2.apk
    package: fm.last.android, sourceDir: /data/app/fm.last.android-1.apk
    

    So, this way you will find path of all apps apk.

提交回复
热议问题