android 检查 write_external_storage,android – 如何知道何时需要WRITE_EXTERNAL_STORAGE

当您的应用程序需要写入外部存储时,您可以看到

here只需要请求

WRITE_EXTERNAL_STORAGE.

但:

Starting in API level 19, this permission is not required to

read/write files in your application-specific directories returned by

getExternalFilesDir(String) and getExternalCacheDir().

首先,我建议您避免使用Intents请求权限,因为这是一种最佳实践,可以提高用户体验.

如果您不能使用Intent来避免使用您的应用程序进行编写,并且您知道有一天用户必须在外部编写,我认为更好的方法是在用户第一次“写入”时请求权限外部存储“路径.

据我所知,在API23中你只需要一次请求权限,所以我认为最简单的方法是在用户第一次要求权限时请求权限,我想当他执行时再一次,权限将继续被接受.您可以使用显示的程序here检查授予的权限.

Here你可以看到:

The user is prompted to give permission once, either at run time or at install time (depending on the user’s Android version). After that, your app can perform the operation without requiring additional interaction from the user. However, if the user doesn’t grant the permission (or revokes it later on), your app becomes unable to perform the operation at all.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值