Reputation: 353
DocumentsProvider API is the only official way to manage files on the removable storage since Android 5.0. But, seems, it does not support even basic functionality. Or, maybe, I missed something?
Create a new document (file) with a non-standard extension.
DocumentsContract.createDocument(contentResolver, uri, mimeType, name)
appends an extension according to the mimeType. For example, it adds .txt
for 'text/plain' MIME-type. The question is: Can I create a file with the name file.abc
? If no, can I register a new MIME-type, which will be linked to abc
extension?
Move a document.
DocumentsContract.renameDocument(contentResolver, uri, newName)
can rename a document. But can I move a document into another directory (change the parent of the document)? Must I create a new document, copy the content from the old one, and delete the old document?
Set the modification date of the document.
This operation can be useful in some situation. For example, in the case I must emulate filesystem move
operation for the question 2. Is there a way to set any required modification time for a document?
Upvotes: 4
Views: 1322
Reputation: 167
Yes you can, but it also depends on how DocumentProvider is implemented by the device manufacturer.
You can only rename, its parent cannot be moved. You're right about creating a new document.
No, setting last modified date is not allowed till Android 6.0. Maybe in future.
Upvotes: 1