Anusha B Anusha B - 7 months ago 53
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("."));
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download