This must be, supposedly, a very simple task, but I've been around it for some time without successes...
In my app I create a folder in the SD card, where I store temporary jpg files. Since I don't want my app to show those temp files when browsing the phone for images, I was trying to make that folder hidden. So, right after creation the dir, I tried to rename it, like this:
String tmppath="/sdcard/myapp/tmp";
try
{
//this creates a directory named TMP -->OK!
File f=new File(tmppath);
if(!f.isDirectory())
f.mkdirs();
//this was supposed to rename the directory to .TMP, but isn't working...
Process process=Runtime.getRuntime().exec("mv "+tmppath +" /sdcard/myapp/.tmp/");
process.waitFor();
}
catch(SecurityException e)
{
}
catch(IOException e)
{
}
catch (InterruptedException e)
{
}
Any thoughts?
File file = new File("your old file name");
File file2 = new File("your new file name");
boolean success = file.renameTo(file2);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With