5

Just out of curiosity, I wanted to know where on the file system of an Android device the application icons are stored.

Like I have shortcuts to various applications on the homescreen of my device, where those icons files (or images) are stored. Is it only inside the application package (.apk) or Android stores it some where else?

If it is in application package only does Android loads all the imagess from each of the apk and loads it when it is started for the first time?

Mayank
  • 1,099
  • 4
  • 17
  • 44

2 Answers2

2

When an app file is installed, the .apk file is analyzed and various items of information are extracted by the launcher. (This process does not involve loading and running the app itself.) Among these items is the app icon, which the launcher typically caches in its own private area. Exactly how this is done depends on the launcher currently active on your device. You might be able to browse through the source for your launcher to find out more details about how it caches these items extracted from the app .apk files, but I'm not sure what practical use there would be to that exercise.

The launcher's use of its own cache greatly speeds up start-up, as otherwise every installed app would have to be scanned at every reboot to extract the requisite information for the launcher to show itself. However, the cache is the source of occasional problems, such as the icon not updating right away when an updated app (with a new icon and possibly a new app name) is installed. (See, for example, this thread and this one.)

Community
  • 1
  • 1
Ted Hopp
  • 232,168
  • 48
  • 399
  • 521
  • As per my understanding, the launcher should also be an application with a .apk file. Where can I find that apk file ? – Mayank May 23 '14 at 04:50
  • @Mayank - It depends on how it was installed. System apps are kept in /system/app. User-installed apps are in /data/app. The default launcher is a system app, but the device may be running a user-installed launcher instead. – Ted Hopp May 23 '14 at 05:07
  • In my device I am using defualt launcher only and I have checked the the directory `/system/app` with a File Manager app in my Android device, there is now such `launcher` app there – Mayank May 23 '14 at 05:09
  • @Mayank - What version of Android are you running? More recent API levels have much higher levels of privacy protection and your file manager app may not have the privilege to see the files there. Try connecting through `adb shell`. On my device (running 4.1.2), it's `/system/app/Launcher2.apk`. – Ted Hopp May 23 '14 at 05:28
  • @Mayank - Ah. KitKat comes with a brand new launcher. I don't know what the .apk is called when it's shipped with the system. The launcher is available from third-party sites, where the file is named GoogleHome.apk, but in my emulator (I don't have a 4.4.2 device), I can't find it under that name. But it's there somewhere. – Ted Hopp May 23 '14 at 06:31
1

Think about what happens when you create your own app. Typically, you create icons for your app for all drawable resource buckets (or at least the ones you want to support). Then these files get packaged with AAPT into the apk with the rest of your project. Then after installing your app, the OS will pick the icon that matches your phone configuration and create a shortcut on your installed apps page.

Emmanuel
  • 13,083
  • 4
  • 39
  • 53