简体   繁体   English

在Android 5.0+中从外部存储删除文件

[英]Deleting Files From External Storage in Android 5.0+

Before Android 4.4, we could easily delete files from any sd card directories. 在Android 4.4之前,我们可以轻松地从任何SD卡目录中删除文件。 After 4.4 this is removed, even with WRITE_EXTERNAL_STORAGE permission you couldn't do it (except with some hacks with ContentProviders). 在4.4之后,即使拥有WRITE_EXTERNAL_STORAGE权限,您也无法做到这一点(除了ContentProviders的一些骇客)。 But I heard after 5.0 this ability is re-added (don't know if it's wrong). 但是我听说在5.0之后会重新添加此功能(不知道这是错的)。 I tried File.delete() method but it's no different than 4.4 for me. 我尝试了File.delete()方法,但对我来说它与4.4没有什么不同。 Is there any way of deleting a file from sdcard in Android 5.0+ ? 有什么办法可以从Android 5.0+的sdcard中删除文件?

您可以通过SAF向用户请求sdcard的权限: 如何使用为Android 5.0(Lollipop)提供的新SD卡访问API?

I was also facing the same problem in my Android version 5.0 but now I have no worries regarding this as I found the solution of this problem. 我在Android 5.0版中也遇到了同样的问题,但是现在我对此无忧,因为我找到了解决此问题的方法。 Just do as I said: go to playstore and download "X-plore File manager" and delete whatever you want from your external storage as well as internal storage. 就像我说的一样:进入playstore并下载“ X-plore文件管理器”,然后从外部存储以及内部存储中删除所需的任何内容。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM