I need to fetch an audio file from SD Card and play it. I think this can be done by getting URI of an audio file. So, to pick an audio file I\'m using following code:
//To pick audio file from device. Place below code in calling activity
int REQUEST_CODE = 1001;
Intent audioIntent = new Intent(Intent.ACTION_PICK, android.provider.MediaStore.Audio.Media.EXTERNAL_CONTENT_URI);
startActivityForResult(audioIntent,REQUEST_CODE);
// Override onActivityForResult
method in activity
@Override
protected void onActivityResult(int requestCode,int resultCode,Intent data){
if(requestCode == REQUEST_CODE && resultCode == RESULT_OK ){
//the selected audio.Do some thing with uri
Uri uri = data.getData();
}
super.onActivityResult(requestCode, resultCode, data);
}