简体   繁体   中英

can I open a folder of type /data/user/0/my.app/app_files/dir_name in android's default file browser programatically?

I am using Android Studio 4.1.3 and am writing code in Java.
I have an app that outputs a number of mp3 files.
My initial idea was after the app does it's job and generates sed files I would make a snackbar with a button appear and upon taping sed button the folder where sed mp3 files are stored.
The idea was that the user would just check out the files and listen to them and see if they have been generated correctly and so on.
I have tried doing this in a number of ways using intents.
Like this for example: Intent intent = new Intent(Intent.ACTION_VIEW) But I haven't managed to get anything working.

Is there any way this could possibly be done?
Should I store the files somewhere else?
Would that make it easier to open the output folder?
Should I read the output folder within my application and create a new activity/fragment where I output the content of the folder and open the default sound app when the user taps on a generated mp3 file(basically doing everything inhouse)?
I want everything to work as well as possible on a generic android phone with no 3rd party apps installed.
Thank you.

The path your are refererring to is Internal App storage . This is supposed to be used for apps internal files which you don't want user or other apps to access.

So you can only access it within your app.

Doing everything in-house as you said will work, but is very limited in my opinion.

So it is better to store it in publicly accessible storage unless the data you are storing is sensitive/private.

To make your files publicly accessible, you have to use External App storage using getExternalFilesDir() or getExternalCacheDir() and store your files there.

You can then launch an intent to open the file path.

Alternatively, if you want your Audio files to listed under Media library, you can use MediaStore API

More info on Data storage - https://developer.android.com/training/data-storage

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM