0

I want to move a DocumentFile from one Location to another. The Uris are aquired via ACTION_OPEN_DOCUMENTTREE and stored.

However, when i try:

val resolver = context.contentResolver
val srcUri = Uri.parse(myUriFromACTION_OPEN_DOCUMENT_TREE)
val srcDocument = DocumentFile.fromTreeUri(context, srcUri)
val targetUri = anotherUriFromACTION_OPEN_DOCUMENT_TREE

DocumentsContract.moveDocument(resolver, srcUri, srcDocument.uri, targetUri )

I get an error:

  java.lang.IllegalArgumentException: Invalid URI: content://com.android.externalstorage.documents/tree/primary%3Anew%20test%20folder%2FTdf%2FmayBeDeleted%2Fexterner

I have not found a way to convert the TreeUri to a normal one. Is this the problem? If so, how is it done?

sanlalala
  • 17
  • 4
  • Btw. the Uri in the error message is my srcUri; but i guess the target Uri wont be accepted either. – sanlalala Mar 10 '20 at 01:12
  • Your target uri is an existing folder. Like your source uri. I think the target folder should be non existing. – blackapps Mar 10 '20 at 12:23
  • moveDocument takes three uris as parameter. You did not explain what they should be and how you used those parameters. – blackapps Mar 10 '20 at 12:26
  • ok, all three uris are similar constructed: content://com.android.externalstorage.documents/tree/primary:%3Anew%20test%20folder%2 pointing to my source folder, content://com.android.externalstorage.documents/tree/primary:%3Anew%20test%20folder%20myFile.acc my file at this location and content://com.android.externalstorage.documents/tree/primary:%3Aother%20folder my target; can I somehow move my file with these parameters? – sanlalala Mar 13 '20 at 02:02
  • Please remove that comment as it is unreadable. Put all info in your post please. – blackapps Mar 13 '20 at 09:32

0 Answers0