Anusha B Anusha B - 1 month ago 14
Android Question

How to get only audio and video name without the .mp3 and .mp4 extention in android

I have audio and video names like this :

azan1(1).mp3 and Funny.mp4

So I need an only AudioName as azan and VideoName as Funny. Need to replace .mp3 and .mp4 from the string 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("."));