android 判断 sdcard 是否是 emulated

最近遇到了无法通过 pm 命令使用系统的安装器把 apk 安装到 sdcard 的问题,返回 

Failure [INSTALL_FAILED_INSUFFICIENT_STORAGE]

主要原因是 emulated sdcard 不能安装 apk,因此在安装之前需要判断 sdcard 是否是 emulated。
这个功能系统已经提供了api,Environment.isExternalStorageEmulated();

Returns whether the device has an external storage device which is emulated. If true, the device does not have real external storage, and the directory returned by getExternalStorageDirectory() will be allocated using a portion of the internal storage system.

Certain system services, such as the package manager, use this to determine where to install an application.

Emulated external storage may also be encrypted - see android.app.admin.DevicePolicyManager.setStorageEncryption(android.content.ComponentName, boolean) for additional details.


  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值