How to rename a file on sdcard with Android application?

前端 未结 4 1768
暖寄归人
暖寄归人 2020-11-28 10:02

In my Android application, I want to rename the file name at runtime. How can I do it?

This is my code:

String[] command = {\" mv\", \"sun moon.jpg\"         


        
4条回答
  •  醉酒成梦
    2020-11-28 10:52

    you can also explicitly give the full path without specifying directory...

    File file = new File("Path of file which you want to rename");
    File file2 = new File("new name for the file");
        boolean success = file.renameTo(file2);
    

提交回复
热议问题