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\"
I tried adding permissions. Even though it did not work, adding File1.setWritable(true);
enabled me to rename the file.
Below is my code snippet:
if(from.setWritable(true))
Log.d("InsertFragmentTwo ", "FileName==> Is Writable");
File two = new File(sdcard,""+imageCount+"."+s.substring((s.lastIndexOf(".")+1)));
if (from.renameTo(two)) {
Log.d("InsertFragmentTwo ", "New FileName==> " + temp);
imageCount++;
retrofitImageUpload(temp);
} else
Log.d("InsertFragmentTwo ", "File Renaming Failed");