How to perform basic operations on files using DocumentFile API?

这一生的挚爱 提交于 2020-01-25 00:11:07

问题


Background

Starting from API 21 (Lollipop), apps can get a special "permission" to modify real SD-cards, as shown on previous posts I've written (here and here).

The problem

I can delete files, and I can also create them, but I can't find a way to perform other basic file operations:

  • read, write, using InputStream and OutputStream
  • move files.
  • create a folder and not just a file
  • rename a file
  • get file info (recent updated,etc...)
  • share/open the file via other apps.
  • other operations I might have forgot about.

The question

How do I get those features? Surely it's possible to perform basic read and write, for example...


回答1:


Using FileUilts for Lollipop gives you most of those options, have you seen this: https://github.com/jeisfeld/Augendiagnose/blob/master/Augendiagnose/src/de/eisfeldj/augendiagnose/util/imagefile/FileUtil.java ?

(I could not add a comment)



来源:https://stackoverflow.com/questions/32019734/how-to-perform-basic-operations-on-files-using-documentfile-api

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!