I am trying to figure out how to get the name of the original .apk file from which an application was installed. I know that you can retrieve the package name and the source directory of the installed application by using the ApplicationInfo
class (described here: Android: how to get the name of apk file programmatically?) but this is NOT what I want.
As an example, suppose I have a simple application that is named TestApp
(via the android:label
tag in the AndroidManifest.xml
file). Furthermore, suppose I generate an .apk file for the application above, rename said .apk file to TestApp_JohnDoe.apk
, and then email that application to John Doe for installation. When John Doe installs the application by clicking on the .apk file I would like to be able to read the filename of the original .apk, TestApp_JohnDoe.apk
, that I sent to him. Using the ApplicationInfo
class, more specifically the sourceDir
method gives me the install directory and application name, /data/app/TestApp.apk
, which is not what I am looking for. I know that it is probably possible to scan all available directories looking for the original .apk file, but I am hoping to avoid this.
In summary, I would like to programatically retrieve the .apk filename/source directory of the installer .apk, such as /storage/sdcard0/Download/TestApp_JohnDoe.apk
, as opposed to the .apk filename/source directory of the actual installed application, /data/app/TestApp.apk
.