在代码上重命名 Android 文件夹
Rename Android Folder on code
我想用 android 中的 java 代码更改文件夹名称。
例如 :
将 "Picture" 文件夹名称更改为 "MyPicture"
请帮我。
谢谢
要以编程方式更改文件夹的名称,请使用 renameTo()
方法:
File oldFolder = new File(Environment.getExternalStorageDirectory(),"old folder name");
File newFolder = new File(Environment.getExternalStorageDirectory(),"new folder name");
boolean success = oldFolder.renameTo(newFolder);
在这里您可以找到有关 renameTo()
方法的信息:
http://www.tutorialspoint.com/java/io/file_renameto.htm
使用renameTo()
方法:
File oldfolder = new File("path of the old folder","old name");
File newfolder = new File("path of the new folder","new name");
oldfolder.renameTo(newfolder);
我想用 android 中的 java 代码更改文件夹名称。 例如 : 将 "Picture" 文件夹名称更改为 "MyPicture" 请帮我。 谢谢
要以编程方式更改文件夹的名称,请使用 renameTo()
方法:
File oldFolder = new File(Environment.getExternalStorageDirectory(),"old folder name");
File newFolder = new File(Environment.getExternalStorageDirectory(),"new folder name");
boolean success = oldFolder.renameTo(newFolder);
在这里您可以找到有关 renameTo()
方法的信息:
http://www.tutorialspoint.com/java/io/file_renameto.htm
使用renameTo()
方法:
File oldfolder = new File("path of the old folder","old name");
File newfolder = new File("path of the new folder","new name");
oldfolder.renameTo(newfolder);