For example, if I install Google Chrome on my phone (assume it's not prebuilt), whatever the original name of the apk is, it will usually be installed to /data/app/com.android.chrome-1.apk but sometimes /data/app/com.android.chrome-2.apk and even xxx-3.apk or xxx-4.apk
My question is what the number in that case mean and how is it generated? It's often varying and I haven't found any clue.


The number has no special meanings. It is used to distinguish old and new packages during installation. While installing an app, the Package Installer first finds an available 'packageid-number' pattern, with the number incrementing from 1, and creates the directory (APK file for Android 5.0 and under). Then it places the APK file in it and removes the old one. Therefore, most commonly the number only varies from 1 to 2 because only one instance of an installed app exists. Summing up the old app and the temporary name, there can only be 2 instances. If you have, by some other means like installing 2 of the same app using a parallel container, there can be up to 4 instances of the app, thus creating com.example-4.

Here's my experiment on Android 5.1.1, using Root Explorer to install the app and Terminal Emulator to monitor directory content change.
Preparation: Use XInstaller (an Xposed module) to allow downgrade installing app (so that I can repeatedly install the same version of an app).
1. Tap the prepared APK file in Root Explorer to install it. In my case, it's Termux.
2. Repeatedly run

root@android:/data/app # ls -d com.termux-*

First: com.termux-1
After some time: com.termux-1 com.termux-2
After more time and finally: com.termux-2
3. Tap the APK to install it again and repeat Step 2.
First: com.termux-2
After some time: com.termux-1 com.termux-2
After more time and finally: com.termux-1
4. Create placeholder directories named com.termux-2, com.termux-3, com.termux-4 and set correct permissions.
5. Repeat Step 3.

com.termux-1  com.termux-2  com.termux-3  com.termux-4
After some time:
com.termux-1  com.termux-2  com.termux-3  com.termux-4  com.termux-5
After more time and finally:
com.termux-2  com.termux-3  com.termux-4  com.termux-5
Where com.termux-2, com.termux-3, com.termux-4 are all empty as they are created by me, not the Package Installer. To verify, run

root@android:/data/app # pm list packages -f | grep com.termux

If you first install the package, it will have a "-1" appended to the folder name. Every time you update the same package without uninstalling, regardless of how it's done, the number increments by itself.

  • Did some experiments and I'm going to answer it myself. – iBug Jan 31 '17 at 11:27
  • 1
    Looking forward to it. Dedicated experiment > occasional experience. – Andy Yan Jan 31 '17 at 11:46

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.