I Want Get Audio Files In Sd Card
In my app I want to set the ringtone when I get an incoming call... How to open the SDCARD and get audio files and list it.. How to get the URI for the selected audio file..
Solution 1:
MediaScanner finds music for you, populating the MediaStore database. Here's some code to look up a music entry:
finalUriuri= MediaStore.Audio.Media.EXTERNAL_CONTENT_URI;
final String[] cursor_cols = {
MediaStore.Audio.Media._ID,
MediaStore.Audio.Media.ARTIST,
MediaStore.Audio.Media.ALBUM,
MediaStore.Audio.Media.TITLE,
};
finalStringwhere= MediaStore.Audio.Media.IS_MUSIC + "=1";
finalCursorcursor= getContentResolver().query(uri, cursor_cols, where, null, null);
cursor.moveToNext();
finalStringartist= cursor.getString(_cursor.getColumnIndexOrThrow(MediaStore.Audio.Media.ARTIST));
finalStringalbum= cursor.getString(_cursor.getColumnIndexOrThrow(MediaStore.Audio.Media.ALBUM));
finalStringtrack= cursor.getString(_cursor.getColumnIndexOrThrow(MediaStore.Audio.Media.TITLE));
doSomethingHere(artist, album, track);
The "data" field contains a handle you can use with MediaPlayer. while doing this media files scanning and indexing for the first time, scan it using a AsyncTask, but later when a intent is received do it using a service.
Post a Comment for "I Want Get Audio Files In Sd Card"