2012-10-21 48 views
0

我如何知道一個文件是否可以被我的android應用程序刪除?如何檢查是否可以通過android應用程序刪除文件?

我正在寫一個android應用程序和一個web應用程序,這將允許我的客戶端查看和刪除他們的文件。 但我不會讓客戶端查看不可刪除的文件。

if(isFileCanBeDeleted("filename.ext")) 
{ 
    //save the filename and path to server 
} 
else 
{ 
    //the file is cannot be deleted, this filename will not be saved online 
} 

回答

0

你可以通過執行shell命令嘗試,

Runtime.getRuntime().exec("test -e " + "/path/to/file.txt"); 

但是,你需要檢查API引用外殼運行時是否可用與否,取決於API級別,或根/無根電話。

相關問題