Noor Noor - 8 months ago 38
Android Question

How to access downloaded audios folder in android app

I am developing a simple audio streaming android app. While playing audios from the URLs, the app also has an option to download the file. The audio files are being downloaded in Internal Storage/voices folder. How can I show all the downloaded audios of this folder in my app? I want to access all the audios in voices folder and show in my app so the users don't need to search the files manually. Please guide. Thank you!

String path = Environment.getExternalStorageDirectory().toString()+"/voices";
Log.d("Files", "Path: " + path);
File directory = new File(path);
File[] files = directory.listFiles();
Log.d("Files", "Size: "+ files.length);
for (int i = 0; i < files.length; i++)
    Log.d("Files", "FileName:" + files[i].getName());

This way you will get all the files stored in voices directory into files array.