Stack Overflow上有一个答案解释了系统在移动App时具体做的事。
http://stackoverflow.com/questions/13043783/android-move-app-to-sd
Q:
Actually I want to find that what kind of items that are involved when we move the app to sd card? I have tried to search, but all the answer point me to "how to move app to sd" but actually I just want to know what items been move to sd and what items are left. I can see that there is still some memory left (in internal memory) when I move the app to sd. I am just curious what are the things left ? Where actually the app move to (in which part of the sd card)?
A:
Good Question!
Let me explain you with an example package say "com.example.app"
Now, when a app is installed for the first time, a new folder will be created by the name
/data/com.example.app
Inside this will contain all the app private data.
Similary, the APK itself is contained in
/data/app/com.example.app-1.apk
Now, when we move application to external storage, the following happens.
- It will not be moved to /mnt/sdcard/ partition
- Android will create a new folder under /mnt/asec partiton called
/mnt/asec/com.example.app
. You can reach this path using any File Manager apps as it has rw permissions - It will create a copy of libs directory if any and move all the files, databases here.
- It will also copy the APK from "/data/app/com.example.app-1.apk" to
/mnt/asec/com.example.app/com.example.app-1.apk
In this way, /data
partition space will be saved and can be reused for other apps. This is a good trick to use when phone gets low on /data storage to move apps to external storage.
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------
以我本机的UC浏览器为例,主要做了这些:
internal memory:
有一个lib文件夹,里面都是.so文件
lib: /data/data/com.UCMobile/lib
还有一个APK文件
apk: /data/app/com.UCMobile-1.apk
SDCard:
移动到SD卡以后,lib就被移动到这个位置
lib: /mnt/asec/com.UCMobile-1/lib
APK被移动到
apk: /mnt/asec/com.UCMobile-1/pkg.apk