How i get list of all Mp3 files from a specific folder?
My folder is
FILE_PATH = Environment.getExternalStorageDirectory().getPath() + "/my folder/"
This following code show all mp3 from all Folder .. i want sow mp3 from my folder only
Cursor createCursor(String filter) {
ArrayList<String> args = new ArrayList<String>();
String selection;
if (mShowAll) {
selection = "(_DATA LIKE ?)";
args.add("%");
} else {
selection = "(";
for (String extension : CheapSoundFile.getSupportedExtensions()) {
args.add("%." + extension);
if (selection.length() > 1) {
selection += " OR ";
}
selection += "(_DATA LIKE ?)";
selection = selection + "AND (IS_MUSIC=1)";
}
selection += ")";
selection = "(" + selection + ") AND (_DATA NOT LIKE ?)";
args.add("%espeak-data/scratch%");
}
if (filter != null && filter.length() > 0) {
filter = "%" + filter + "%";
selection =
"(" + selection + " AND " +
"((TITLE LIKE ?) OR (ARTIST LIKE ?) OR (ALBUM LIKE ?)))";
args.add(filter);
args.add(filter);
args.add(filter);
}
This one is Working fine
Cursor createCursor(String filter) {
ArrayList<String> args = new ArrayList<String>();
String path = Environment.getExternalStorageDirectory().getPath();
String selection = MediaStore.Audio.Media.IS_MUSIC + " !=" + 0
+ " AND " + MediaStore.Audio.Media.DATA + " LIKE '" + path
+ "/Fast Mp3 Downloader/%'";
if (filter != null && filter.length() > 0) {
filter = "%" + filter + "%";
selection =
"(" + selection + " AND " +
"((TITLE LIKE ?) OR (ARTIST LIKE ?) OR (ALBUM LIKE ?)))";
args.add(filter);
args.add(filter);
args.add(filter);
}
String[] argsArray = args.toArray(new String[args.size()]);
getExternalAudioCursor(selection, argsArray);
getInternalAudioCursor(selection, argsArray);
Cursor c = new MergeCursor(new Cursor[] {
getExternalAudioCursor(selection, argsArray),
getInternalAudioCursor(selection, argsArray)});
startManagingCursor(c);
return c;
}