Comments (3)
I want access to the whole root
I understand that you want to create a folder without prompt any dialogs to the user, i.e. /storage/emulated/0/YourAppName
, but you can't do that since API 30 without full disk access (android.permission.MANAGE_EXTERNAL_STORAGE
).
Even WhatsApp is no longer able to create custom directory like /storage/emulated/0/WhatsApp
since Android 12 (reference: #107 (comment)). Thus requesting root access is not a future-proof solution. The best solution is by writing your audio files inside your app's private directory, for example:
context.getExternalMediaDirs()
will return/storage/emulated/0/Android/media/<app-package>
(current WhatsApp solution)context.getExternalFilesDir(Environment.DIRECTORY_RECORDINGS)
will return/storage/emulated/0/Android/data/<app-package>/files/Recordings
Those paths do not require any storage permissions.
it crashes and it reverts back to the original Login Activity
You're trying to create an enum from string /storage/emulated/0
, which is not available in the enum constants. Use available constants from this file: PublicDirectory.kt
, for example PublicDirectory.MUSIC
, PublicDirectory.DOWNLOADS
, etc.
from simplestorage.
Can you give me an example? How should I go about implementing it?
from simplestorage.
Here's the example:
val input = URL("https://google.com/audio.mp3").openStream()
val folder = externalMediaDirs.first()
val file = File(folder, "recitation.mp3")
val output = file.outputStream()
// will be located in /storage/emulated/0/Android/media/<app-package>/recitation.mp3
output.write(input.read())
from simplestorage.
Related Issues (20)
- How to regain access to a folder of DocumentFile or DocumentFileCompat outside of callbacks? HOT 9
- How to overwrite/truncate an already existing file? HOT 2
- Is there some way to listen for changes under a tree URI or at least over a single document URI? HOT 1
- Just a question to cloud storages like GoogleDrive / Dropbox
- Request codes must be unique. File picker=3, Folder picker=0, Storage access=0, Create file=4 HOT 1
- IllegalArgumentsException: Empty Storage ID HOT 4
- Execution failed for task ':app:mergeDebugResources'
- On Android 13 device hasStorageAccess returns false HOT 1
- How can i set specific path or uri in storageHelper.openFilePicker(REQUEST_CODE_PICK_FILE_FOR_RENAME)? HOT 1
- Awesome HOT 1
- Case when permission is canceled was not handled HOT 5
- Not working on complieSDK/targetSDK 33 HOT 3
- filterMimeTypes not working with single or mulitple mime types HOT 1
- Judgment of permissions is not accurate
- Error " java.lang.IllegalArgumentException: Request codes must be unique" similar to Issue #93 in 1.5.5 HOT 2
- Full Access above 33 using MANAGE_EXTERNAL_STORAGE HOT 1
- multiple mime type HOT 1
- Fully support coroutines HOT 2
- [QA/Bug] getting permission denied HOT 2
- How can I specify to obtain files of certain formats, and then customize the view to display these files, such as PDF files? HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from simplestorage.