-1

是否可以在知道包名称的情况下制作 .apk 文件的副本?例如,我有一个名为:的包com.example.package,我想在sdcard/mydir/. 你能帮助我吗?

4

1 回答 1

0

This ought to work:

String package = "com.mydomain.mypackage";
PackageManager pm = this.getPackageManager();
ApplicationInfo ai = pm.getApplicationInfo( package, PackageManager.GET_META_DATA );
String sourceDir = ai.sourceDir;

After that, sourceDir should hold the path of the .apk and you can copy it just as any other file. Keep in mind to wrap this in try...catch in case the package doesn't exist.

于 2013-04-27T14:32:20.570 回答