I am developing File Manager, I have one issue in android version 30, when I get listFile() of OTG path its not return file, the only way to get all files is from DocumentFile, but now I want to get file as File from that DocumentFile how do I get, plz support me.
How to get File from DocumentFile in android version 29+ for File Manager App?
375 Views Asked by Developer_ rahul At
2
There are 2 best solutions below
0
blackapps
On
USB OTG drives are often not mentioned any more in getExternalFilesDirs().
So you have no path.
Only with SAF ACTION_GET_DOCUMENT_TREE you can get an uri to the drive or folders on the drive.
Now its pretty easy to convert such an uri to a flie system path.(Look at all kinds of getRealFileForUri() implementations).
But even if you manage to get a path it is not usable.
Related Questions in ANDROID
- Creating global Class holder
- Flutter + Dart: Editing name of a tab shows up a black screen
- android-pdf-viewer Received status code 401 from server: Unauthorized
- Sdk 34 WRITE_EXTERNAL_STORAGE not working
- ussd reader in Recket Native module
- Incorrect display of LinearGradientBrush in IOS
- The Binary Version Of its metadata is 1.8.0, expected Version is 1.6.0 build error
- I can't make TextInput to auto expand properly in Android
- Creating multiple instances of a class with different initializing values in Flutter
- How to create a lottie animation
- making android analyze with coverity sast tool
- Flutter plugin development android src not opening after opening example
- I initialize my ViewModel in the Activity with several fragments as tabs, but the fragments(tabs) return null for the updated livedata
- Node.js Server + Socket.IO + Android Mobile Applicatoin XHR Polling Error...?
- How I can use the shared preferences class?
Related Questions in FILE
- Helpt with reading files
- Why can't I use the file pointer after the first read attempt fails?
- Can't read the file using std::wifstream C++
- How can the scanner reread the entire file after it has already executed hasNextLine once?
- What is 'Invalid Load Key, '\x00'
- php $_FILE variable undefined index
- Data loaded from the file is not returned in the correct order
- File splitting and encryption
- Optimizing an s5cmd command that uses awk to generate a text file
- segmentation fault while reading in text file ( c++ )
- File.OpenText is adding C:\ to the front which is an error
- UTF-8 issue with excel
- How to upload files to MediaWiki APIs in Rust?
- No such file or directory: '/tmp/tmp_ejr26m6.upload.mp3' in Django
- Problems accessing zip files on the react front end from express backend
Related Questions in ANDROID-11
- Mediastyle notifications not working in android 11
- Android 11- Location One-Time Permission, how to know if this was selected by the user
- Save in Contacts works in Android 10 but not in Android 11
- Android 11 - window.setDecorFitsSystemWindow doesn't show screen behind Status and Navigation Bars
- Xamarin: Saving files to external storage on Android with an API level >=29
- Android 11. ContentResolver.query return empty cursor
- Write permissions not working - scoped storage Android SDK 30 (aka Android 11)
- Google PanoramaAPI stopped working on Android 11
- java.lang.IllegalArgumentException: Unknown URI when trying to open downloaded image
- Android 11 app crash with "The meta-data tag in your app's AndroidManifest.xml does not have the right value. Expected 12451000 but found 4323000"
- Creating a new sharable text file using Flutter in Android 10 and above
- Access Microphone / Camera in background in Android 11
- Cannot take a photo programmatically on Android 11 - intent returns canceled status
- Background Microphone access in Android 11 throws exception
- SpeechRecognizer not available when targeting Android 11
Related Questions in STORAGE-ACCESS-FRAMEWORK
- How to programmatically move , copy files to SD?
- startActivityForResultIntent result=None
- how to use Storage Access Framework in a simple file upload code Button?
- Saving an image after getting folder from Storage Access Framework UI
- Writing with an OutputStream to a DocumentFile: data seem to be written but file ends up empty
- Get a DocumentFile that is a child of a document tree without using findFiles()
- MP3 JID3 Library amendments
- On some devices ACTION_OPEN_DOCUMENT_TREE doesn't show the chooser
- Error in creating a folder using Storage Access Framework
- Android Storage Access Framework: QuickOffice doesn't show error when saving document
- No activity found to handle Intent - android.intent.action.OPEN_DOCUMENT
- Android 13 - How to save a pdf to external storage?
- Access Files on a USB OTG device (SD Card reader) via MediaStore
- MediaStore.getVolumeName(uri) - java.lang.IllegalArgumentException: Missing volume name
- Unable to find folders in the directory tree in Android (Kotlin)
Related Questions in DOCUMENTFILE
- How to save changes in Plain Text Content Control in docx file using python
- Android get folder of single DocumentFile (uriForFile)
- Can't use DocumentsContract.getDocumentId on uri gotten from ActivityResultContracts.OpenDocumentTree()
- Android app: Differentiate "folder deleted" from "permission removed" for this folder
- opening an external "file explorer" app: how to get absolute path from a uri pointing to a folder
- Android 11 - Unable to copy file, 'NO_SPACE_LEFT_ON_TARGET_PATH' despite having a lot of space using SimpleStorage API
- How to rewrite DocumentFile completely
- What is the "authority" that DocumentsContract.moveDocument() needs?
- Android 11: ACTION_OPEN_DOCUMENT_TREE get absolute Folder Path
- Opening large SQLite Databases on Android 11
- How to get File from DocumentFile in android version 29+ for File Manager App?
- How to fetch files inside hidden folder using Media Store API on Android 11
- ContentResolver ignoring selection argument whne trying to find a documentfile by name
- Update DATE_MODIFIED in MediaStore on Android 11 with DocumentFile TreeUri
- How to list subfolder content when using Android DocumentFile API
Trending Questions
- UIImageView Frame Doesn't Reflect Constraints
- Is it possible to use adb commands to click on a view by finding its ID?
- How to create a new web character symbol recognizable by html/javascript?
- Why isn't my CSS3 animation smooth in Google Chrome (but very smooth on other browsers)?
- Heap Gives Page Fault
- Connect ffmpeg to Visual Studio 2008
- Both Object- and ValueAnimator jumps when Duration is set above API LvL 24
- How to avoid default initialization of objects in std::vector?
- second argument of the command line arguments in a format other than char** argv or char* argv[]
- How to improve efficiency of algorithm which generates next lexicographic permutation?
- Navigating to the another actvity app getting crash in android
- How to read the particular message format in android and store in sqlite database?
- Resetting inventory status after order is cancelled
- Efficiently compute powers of X in SSE/AVX
- Insert into an external database using ajax and php : POST 500 (Internal Server Error)
Popular Questions
- How do I undo the most recent local commits in Git?
- How can I remove a specific item from an array in JavaScript?
- How do I delete a Git branch locally and remotely?
- Find all files containing a specific text (string) on Linux?
- How do I revert a Git repository to a previous commit?
- How do I create an HTML button that acts like a link?
- How do I check out a remote Git branch?
- How do I force "git pull" to overwrite local files?
- How do I list all files of a directory?
- How to check whether a string contains a substring in JavaScript?
- How do I redirect to another webpage?
- How can I iterate over rows in a Pandas DataFrame?
- How do I convert a String to an int in Java?
- Does Python have a string 'contains' substring method?
- How do I check if a string contains a specific word?
You don't. There's no promise that there is an actual File anywhere, it could be backed by a content provider calculating it at runtime, or reading it from a db. Since a File can only represent a file on disk, there's no way to convert from a DocumentFile to a File.