Questions tagged [documentfile]

DocumentFile Class represent a document backed by either a DocumentsProvider or a raw file on disk.

This is a utility class designed to emulate the traditional File interface. It offers a simplified view of a tree of documents, but it has substantial overhead. For optimal performance and a richer feature set, use the DocumentsContract methods and constants directly.

93 questions
0
votes
1 answer

SAF - decoded Uris seem to be considered as different from encoded ones by SAF methods

I am trying to introduce SAF in my Android app. It seems that the uris from many SAF methods are in encoded form, with characters like : or / being replaced by %3A and %2F, for example. In my app I am decoding uris so they have this…
P5music
  • 3,197
  • 2
  • 32
  • 81
0
votes
1 answer

SAF - Invalid URI error from DocumentsContract.createDocument method (FileOutputStream copy)

My app is migrating to SAF or, at least some experimentation is going about. Now it has to copy a file from private app folder to a SAF folder that was authorized. The used method is: static boolean copyFileToTargetFolderWithNewName(Activity…
0
votes
3 answers

Why do i need write permission external storage to delete a file?

My question is why i need this permission when i'm trying to delete a file from the sdcard, as the permissions says 'Write' it doesn't write anything to the sdcard when i try to delete something so why is this required? I tried removing the…
Vince VD
  • 1,506
  • 17
  • 38
0
votes
1 answer

Using documentfile with Storage Access Framework

I got treeUri from intent's resultdata. I selected sdcard's root path. Casting treeUri to string type's result is content://com.android.externalstorage.documents/tree/C4FD-B5C6%3A. Question 1. Is that result right? Question 2. Anyway, I created…
0
votes
0 answers

Get File uri that is inside treeUri sub Folder

I m trying to get uri of file/folder using loop that is inside subfolder of TreeUri dir. Here is my treeUri for Path /storage/0018-E24D content://com.android.externalstorage.documents/tree/0018-E24D%3A The file is inside the treeUri subfolder…
nhCoder
  • 451
  • 5
  • 11
0
votes
0 answers

DocumentFile.renameTo uses old filename when sharing file through gallery

I have an app that renames images and use the Document Fileprovider to be able to rename files also on the external storage. The renaming works fine, when I check the filename via a filemanager and also when I view the the "Info" in the Google…
JayTee
  • 1,114
  • 2
  • 11
  • 18
0
votes
1 answer

No permission to subfolders to write files with DocumentFile after granting permission to root of SD Card

I'm calling an intent using this: Intent intent = new Intent(Intent.ACTION_OPEN_DOCUMENT_TREE); intent.addFlags(Intent.FLAG_GRANT_WRITE_URI_PERMISSION); startActivityForResult(intent, 42); and selecting the root of my external SD card then taking…
Blair Holmes
  • 1,521
  • 2
  • 22
  • 35
0
votes
1 answer

video file cant play with Action_View uri got from Document file on removeable Storage

I could just get my files on removable storage by action_open_document tree and it gives me a document file. I can not open this file with Action_view. The URI from document file did work! I can open image file with action view . String…
Mostafa
  • 95
  • 1
  • 10
0
votes
0 answers

Is DocumentFile API broken on encrypted removable SD card on Samsung Galaxy S7?

I have created a zero size file aaa.txt on the root folder of the UNENCRYPTED removable SD card. The file aaa.txt has correct size 0 bytes when I list all entries in the root folder with DocumentFile#listFiles(). If I encrypt removable SD card from…
isabsent
  • 3,683
  • 3
  • 25
  • 46
0
votes
1 answer

DocumentFile : problems creating specific directory name

I have an app that has to create files and directories on the removable sdcard. I use the DocumentFile API. In most of cases, it works, but I have found one case which doesn't work (at least on a Samsung GS7): I cannot create a directory named…
gRRosminet
  • 11
  • 1
0
votes
1 answer

How to set FLAG_SUPPORTS_MOVE to Document?

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…
theuses
  • 294
  • 2
  • 14
0
votes
0 answers

AUDIO_OUTPUT_FLAG_FAST denied by client - Intent.ACTION_OPEN_DOCUMENT_TREE

I want to pick a file from mysdcard (and then I upload to a server). I try to use Intent.ACTION_OPEN_DOCUMENT_TREE to select the file using this post: How to use the new SD card access API presented for Android 5.0 (Lollipop)? but when I try to…
0
votes
1 answer

DocumentFile - direct access to underlying file

Is it somehow possible to get a File object from an DocumentFile? With some small trick I can get the real path of the file, but the File class is not allowed to read/write there... I need to access media files from USB OTG or secondary storage and…
prom85
  • 16,896
  • 17
  • 122
  • 242
0
votes
1 answer

Construct Uri for android 5.0 DocumentFile from ACTION_OPEN_DOCUMENT_TREE root Uri

I can successfully obtain a basepath Uri from OPEN_DOCUMENT_TREE from the Storage Access Framework. How to use the new SD card access API presented for Android 5.0 (Lollipop)? private static final int READ_REQUEST_CODE = 42; public void…
boosth
  • 1
  • 3
0
votes
0 answers

Install apk programmatically with DocumentFile

This is how i install a apk file: Intent intent = new Intent(Intent.ACTION_VIEW); intent.setDataAndType(uri, "application/vnd.android.package-archive"); intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); startActivity(intent); Now i want to install a…
cgr
  • 519
  • 1
  • 7
  • 20