Android Question Accessing Music folder files on external SD drive

Danamo

Member
Licensed User
My app needs to play mp3s that are stored in the external SD card. Using "/storage/sdcard1/Music" as the path my app works fine in debugging mode, but when I compile it to Release on my device the app crashes when run.

The app works okay using "DirRootExternal/Music" as the path, but that isn't the external SD card; it's the built-in default music folder of the phone. This would be okay, except my device doesn't have enough memory for the huge number of mp3 files in my collection, so I have to put them on the SD card.

I've noted in discussions in these forums that, apparently, Apps can't access external SD card files except those which are in the App's own installation folders?

If so, then why can my app access the Music folder on the external SD card while running in Debug mode with the IDE interface but not when "Released / Installed" as a stand-alone app on the device?

It seems to me that Apps should be able to access common files such as media or databases which are stored on external SD cards. After all, what is the point of adding external memory to a device if Apps can't use it?

Any advice on how to get my app to read the Music folder files on the external SD card would be much appreciated!
 

NJDude

Expert
Licensed User
Longtime User
Just for reference, using hard coded paths such as "/storage/sdcard1/Music" is not recommended since that can change from device to device.

Writing to external SD cards, that's a little tricky due to the security features Android imposes, search the forums, there are samples about this.
 
Upvote 0

Danamo

Member
Licensed User
Yes, I understand your general point about hard-coding paths. For now, as a beginner, I'm just writing apps for my own device and not too worried about security. I just want them to work, LOL! Using the hard coded path was the only way I have learned, so far. I'll keep searching these forums and tutorials.

Thanks for your input.

Just for reference, using hard coded paths such as "/storage/sdcard1/Music" is not recommended since that can change from device to device.

Writing to external SD cards, that's a little tricky due to the security features Android imposes, search the forums, there are samples about this.
 
Upvote 0
Top