File. RenameTo invalid problem
Case: Rename audio. M4s to audio
Old path: / storage/emulated / 0 / Android/data/XXX. XXX. XXX/audio m4s
New path: / storage/emulated / 0 / Android/data/XXX. XXX. XXX/audio mp3
val audioNew = File(audio.parent, "audio.mp3")
val target = audio.renameTo(audioNew)
Copy the code
instructions
- There must be
write
Jurisdiction:<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
- The path of the old and new files must be an absolute path, that is
"Path + file name +.xxx"
reference
File. RenameTo () returns true, but the File from the then renamed stackoverflow.com/questions/8…
Android File renaming File. RenameTo () deputy specimen method (custom rules), and define blog.csdn.net/XieYupeng52…