Android: Scan music files from specific directories?
<p>I want to  my application to scan for music files only in those folders which I have specified in preferences. So that other music files like audio books do not get included.</p>

<p>Currently, I've written this code, that scans all music files:</p>

<pre><code>private String[] getTrackList() {
        String[] result = null;
        String[] projection = { MediaStore.Audio.Media._ID,
                MediaStore.Audio.Media.DISPLAY_NAME,
                MediaStore.Audio.Media.DATA, MediaStore.Audio.Media.TITLE };
        String selection = MediaStore.Audio.Media.IS_MUSIC + "!=" + 0;
        cursor = managedQuery(MediaStore.Audio.Media.EXTERNAL_CONTENT_URI,
                projection, selection, null, MediaStore.Audio.Media.TITLE
                        + " ASC");
        result = new String[cursor.getCount()];
        int position = 0;
        for (cursor.moveToFirst(); !cursor.isAfterLast(); cursor.moveToNext()) {
            columnIndex = cursor
                    .getColumnIndexOrThrow(MediaStore.Audio.Media.TITLE);
            result[position] = cursor.getString(columnIndex);
            position++;
        }
        return result;
    }
</code></pre>
