I want to implement a simple Media Player.How can i retrieve the full path of Mp3 songs from internal storage in android.
Asked
Active
Viewed 2,069 times
3 Answers
2
If you have any problem search first. do your efforts you'll find it... here's a link try it Get Mp3 from SD card

Community
- 1
- 1

Shashank Verma
- 284
- 4
- 19
-
@ Shashank Verma i want to fetch the file path from device internal storage not from SD card. – May 12 '17 at 05:40
2
mpintro = MediaPlayer.create(this, Uri.parse(Environment.getExternalStorageDirectory().getPath()+ "/Music/intro.mp3"));
mpintro.setLooping(true);
mpintro.start();

pb772
- 539
- 1
- 3
- 14
1
Try this check for file if it exists or not
public static String rootPath = Environment.getExternalStorageDirectory() + "/YourDirectory/";
File file = new File(Environment.getExternalStorageDirectory()
+ "/YourDirectoryFolder/Audio/" + NmaeofFile + "/");
if (!file.exists())
return false;
else{
//Do your work here
}
And then simply start media player
player.setDataSource(rootPath);//rootpath is the path of your file
player.prepare();
player.start();

Abdul Kawee
- 2,687
- 1
- 14
- 26