据说这应该是一项非常简单的任务,但我已经有一段时间没有成功……
在我的应用程序中,我在SD卡中创建了一个文件夹,我存储了临时的jpg文件.由于我不希望我的应用程序在浏览手机图像时显示这些临时文件,因此我试图隐藏该文件夹.所以,在创建dir后,我尝试重命名它,如下所示:
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)
{
}
有什么想法吗?