Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
103 views
in Technique[技术] by (71.8m points)

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

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.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...