Android 在SD和Internal memory之间移动App,具体做了什么?

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

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值