Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get the file *.apk location in Android device

Tags:

android

Need some help by retrieving *.apk file name from Android device programmaticaly ? Could any body provide some Android methods doing that or even shell commands run under Android to get the file location , if I know just a part from file name ?

Also if there is a way how to find out where the *.apk file went after downloading from Market or outside Market ?

Thank you in advance.

like image 295
asteroidg Avatar asked Jan 08 '11 18:01

asteroidg


2 Answers

List<ApplicationInfo> 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
like image 178
John Carter Avatar answered Nov 15 '22 21:11

John Carter


$ adb shell pm list packages -f
like image 38
Joe Bowbeer Avatar answered Nov 15 '22 20:11

Joe Bowbeer