天天看點

android sd卡重命名,android – 重命名SD卡中的檔案夾

據說這應該是一項非常簡單的任務,但我已經有一段時間沒有成功……

在我的應用程式中,我在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)

{

}

有什麼想法嗎?