Giter VIP home page Giter VIP logo

Comments (3)

anggrayudi avatar anggrayudi commented on September 25, 2024

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.

maq796113 avatar maq796113 commented on September 25, 2024

Can you give me an example? How should I go about implementing it?

from simplestorage.

anggrayudi avatar anggrayudi commented on September 25, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.