How to rename a file on sdcard with Android application?
问题 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"," sun_moon,jpg"}; try { Process process = Runtime.getRuntime().exec(command); } catch (IOException e) { Toast.makeText(this, ""+e, Toast.LENGTH_LONG).show(); } I also used renameTo(File f) method but it does not work. 回答1: I would recommend using File.renameTo() rather than running the mv command, since I'm fairly sure the latter isn't supported..