• After 15+ years, we've made a big change: Android Forums is now Early Bird Club. Learn more here.

Android studio rename video file in internal storage

parthag

Lurker
Jan 10, 2022
1
0
Hi All,
I am a complete newbie to android development. I have created an app which takes a 5 second video and stored it in the phones internal storage. The path is shown as "/storage/emulated/0/DCIM/camera" . However I cannot rename the file to a customized file name through code. I am doing the following in my code (assuming filename is the String containing the .mp4 file name:

File dir=new File ("/storage/emulated/0/DCIM/Camera/");
File fromfile=new File (dir,filename);
File tofile=new File(dir,"myname.mp4");
fromfile.renameTo(tofile);

What am I doing wrong? Any help will be appreciated
Thanks
 

BEST TECH IN 2023

We've been tracking upcoming products and ranking the best tech since 2007. Thanks for trusting our opinion: we get rewarded through affiliate links that earn us a commission and we invite you to learn more about us.

Smartphones