Anusha B Anusha B - 1 month ago 13
Java Question

How to get only filename without .mp3 and .mp4 extension in android?

I have audio and video names like this :

- azan1(1).mp3
- Funny.mp4

So I need an only AudioName as azan and VideoName as Funny. I am newbie in android and don't know how can I get only filename? How can I achieve this in code.??

Answer Source

Try this way to get filename without extension:-

if (fileName.indexOf(".") > 0)
   fileName = fileName.substring(0, fileName.lastIndexOf("."));