Rama Krishna Rama Krishna - 10 months ago 38
Android Question

Regular expression for song name in android

In my application i want to display song name.But now it will be showing total song path,like this

String song_name = /storage/Music/Lean on.mp3

but i want to display only song name. that means

String song_name = Lean on.mp3

Can any one help me that what is the regular expressions used for extracting song name for total file path.

Any help could be appreciated thanks in Advance.


You can use subString function with combination of LastInedexOf function. please find below example

String path=":/storage/Music/Lean on.mp3";
String filename=path.substring(path.lastIndexOf("/")+1);