Android examples for android.media:Audio
get Audio Uri From Media Provider
import android.content.Context; import android.database.Cursor; import android.net.Uri; import android.provider.MediaStore.Audio; public class Main { public static final Uri getAudioUriFromMediaProvider(Context ctxt, String audioFile) { String selection = Audio.AudioColumns.DATA + "=?"; String[] selectArgs = { audioFile }; String[] projection = { Audio.AudioColumns._ID }; Cursor c = null;/*from ww w . j a v a 2s . c om*/ try { c = ctxt.getContentResolver().query(android.provider.MediaStore.Audio.Media.EXTERNAL_CONTENT_URI, projection, selection, selectArgs, null); if (c.getCount() > 0) { c.moveToFirst(); String id = c.getString(c.getColumnIndex(Audio.AudioColumns._ID)); return Uri.withAppendedPath(android.provider.MediaStore.Audio.Media.EXTERNAL_CONTENT_URI, id); } return null; } finally { if (c != null) { c.close(); } } } }