I'm creating an app for a private use only... it's not so important then, respect your time :P
What I want to make is an app that reads from a database and plays sounds. I've already made the database and I am able to play sound from res/raw folder. However, there are thousands of files to play and some new ones will be a part of the app and other will be deleted in the future. So, adding a simple file makes me to download the whole app (~1 GB) each time (or maybe I'm wrong?). Instead, I thought of reading an Excel file and playing sounds from SD card then. But I can't... as far as i know:
Apps are not allowed to write (delete, modify ...) to external storage except to their package-specific directories.
I put the files into the /storage/emulated/0/Android/data/my_package_folder/files folder. I've read really many topics and nothing helped me.
Environment.MEDIA_MOUNTED.equals(extStorageState) //returns true
Environment.MEDIA_MOUNTED_READ_ONLY.equals(extStorageState) //returns false
I tried a few ways of creating new file object or playing the sound with the mediaplayer (as I've said before, there's no problem with playing res/raw files) but file.exists always returns false or sound doesn't play:
String filePath = getExternalFilesDir(null) + "/myfile.mp3"; //returns correct file path
File file = new File(filePath);
OR
File file = new File(getExternalFilesDir(null).getPath(), "myfile.mp3");
OR
MediaPlayer mp;
mp = MediaPlayer.create(this, Uri.parse(getExternalFilesDir(null).getPath() + "/myfile.mp3"));
The minSdkVersion is set to 19 so I don't need that line in Manifest:
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
I have included that line and nothing changed:
<uses-permission android:name="android.permission.MOUNT_UNMOUNT_FILESYSTEMS" />
I was also trying to do that with other file extensions. Also, the solution from here didn't help. My phone is Samsung Galaxy Grand Prime (SM-G530FZ), Android v. 5.0.2. Help, please! :)