Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android music files location?

Tags:

android

I'm writing a music player app and I'm wondering where should I look for the user's music files. I want to find all the songs that the Music app normally finds and I'm curious how that app finds the songs. Is there an enum variable for a specific folder? Just a recursive search of the sd card? I know on my phone's sd card there's a Music folder; is that how it is on every android device and should I just recursively search that folder? Or should I just ask the user to find the folder?

like image 401
Corey Ogburn Avatar asked Mar 25 '11 04:03

Corey Ogburn


People also ask

Where are my music files on Android?

From the Home screen, tap Apps > Music Player . The Music Player application searches your phone for music files you copied into it, then builds a catalog of your music based on the information contained in each music file.

Where are music files stored on my phone?

On your phone, you can usually find your files in the Files app . If you can't find the Files app, your device manufacturer might have a different app.

Where are music files stored?

Typically, a computer has one location under which all music files are stored. This location is on your hard (or, more modernly, solid state) disk. Some operating systems have common locations for this. For instance, the default location in Windows is C:\[your username]\My Music\.

Where are mp3s stored on Android?

Downloaded files will be saved to the aptly named “Downloads” folder on your device.


2 Answers

You can find all music files from sdcard using below function.

public void getAllSongsFromSDCARD() 
{
    String[] STAR = { "*" };        
    Uri allsongsuri = MediaStore.Audio.Media.EXTERNAL_CONTENT_URI;
    String selection = MediaStore.Audio.Media.IS_MUSIC + " != 0";

    cursor = managedQuery(allsongsuri, STAR, selection, null, null);

    if (cursor != null) {
        if (cursor.moveToFirst()) {
            do {
                String song_name = cursor
                        .getString(cursor
                                .getColumnIndex(MediaStore.Audio.Media.DISPLAY_NAME));
                int song_id = cursor.getInt(cursor
                        .getColumnIndex(MediaStore.Audio.Media._ID));

                String fullpath = cursor.getString(cursor
                        .getColumnIndex(MediaStore.Audio.Media.DATA));


                String album_name = cursor.getString(cursor
                        .getColumnIndex(MediaStore.Audio.Media.ALBUM));
                int album_id = cursor.getInt(cursor
                        .getColumnIndex(MediaStore.Audio.Media.ALBUM_ID));

                String artist_name = cursor.getString(cursor
                        .getColumnIndex(MediaStore.Audio.Media.ARTIST));
                int artist_id = cursor.getInt(cursor
                        .getColumnIndex(MediaStore.Audio.Media.ARTIST_ID));



            } while (cursor.moveToNext());

        }
        cursor.close();
    }
}
like image 61
Chirag Avatar answered Oct 28 '22 06:10

Chirag


Android automatically scans all external SD cards for audio and indexes this data, see the MediaStore.Audio class for details. This allows you to query by Albums, Artists, Genres and Playlists. If you just want a list of media files can be found by querying the content provider MediaStore.Audio.Media.EXTERNAL_CONTENT_URI.

like image 44
Nic Strong Avatar answered Oct 28 '22 05:10

Nic Strong