I want to search for all my songs on my removeable SDCard but it seems like I only get ringtones and some downloaded music from my internal storage. I have Android 6.0 (Huawei).
private static ArrayList<String> scanDeviceForSongs_All(File startingFolder ){
ArrayList<String> ret = new ArrayList<String>();
if( startingFolder == null )
return ret;
if( startingFolder.list() == null )
return ret;
for( File fileEntry : startingFolder.listFiles() ) {
if( fileEntry.isDirectory() ) {
//recursively add all sub directories
ret.addAll( scanDeviceForSongs_All( fileEntry ) );
} else {
final String path = fileEntry.getAbsolutePath();
if( isAudio( path ) )
ret.add( path );
}
}
return ret;
}
public static boolean isAudio( String s ) {
final String[] supportedFormats = { ".mp3", ".ogg", ".oga", ".wav", ".acc", ".mp4", ".m4a", ".flac", ".3gp", ".mkv" };
//iterate through formats and end if one was found
for( String suffix : supportedFormats ) {
if( s.endsWith( suffix) )
return true;
}
//none were found, either no audio or not supported
return false;
}
I call sometime during the startup scanDeviceForSongs_All( Environment.getExternalStorageDirectory() )
in a Fragment. It works, I do get something, though it is the internal storage that is being analyzed and not my SD-Card which has basically all of my songs.
How do I get the path for my SDCard?