Finally I found out that to move Document
instances I need to (somehow) set FLAG_SUPPORTS_MOVE
to it. But Document
class haven't any setFlag()
or others methods. I tried set flags to URI with getContentResolver().takePersistableUriPermission()
but IDE warns that I use other flags not specified by annotations. I just want to move all files from one folder to other on 25 API.
Asked
Active
Viewed 233 times
0

theuses
- 294
- 2
- 14
1 Answers
2
The client does not set FLAG_SUPPORTS_MOVE
. The DocumentsProvider
advertises whether a document can be moved, renamed, etc. using these sorts of flags. If the provider has added that flag, then you can use moveDocument()
to move the document from one collection to another within the same provider.

CommonsWare
- 986,068
- 189
- 2,389
- 2,491
-
Am I need to implement my own DocumentProvider? Or is there platform-made provider? – theuses Mar 17 '17 at 12:47
-
@constantinopolskaya: "Am I need to implement my own DocumentProvider?" -- probably not. If you could do that, you would have direct filesystem access to whatever it is that you are trying to move, and you would not need any of this. "Or is there platform-made provider?" -- you are already using it, presumably. You have not indicated where this `Uri` is coming from. If it is from `ACTION_OPEN_DOCUMENT`, `ACTION_OPEN_DOCUMENT_TREE`, etc., then that `Uri` was given to you by somebody else's `DocumentProvider`. – CommonsWare Mar 17 '17 at 12:53
-
I got URI from SAF (intent action) so where is DocumentProvider? I'm sorry but I'm struggling at all – theuses Mar 17 '17 at 13:45
-
@constantinopolskaya: "so where is DocumentProvider?" -- it was developed by some other computer programmer. Depending on which document the user selects, it could be a system-supplied `DocumentProvider`, or one from a non-system app (e.g., Google Drive, other third-party apps). Either that provider adds `FLAG_SUPPORTS_MOVE` to its documents, or it does not. – CommonsWare Mar 17 '17 at 13:53
-
@constantinopolskaya The provider is accessible via `ContentResolver` by supplying the Uri. This should probably be added to the documentation of `Uri`… – user1643723 Mar 18 '17 at 08:54