[英]How to know the file is exist in SD Card or Internal Storage in Android
如何得知Android SD卡或內部存儲中是否存在任何文件?
案例:我們沒有確切的位置目錄。 我想檢查任何目錄中的文件。
如果有任何方法或任何示例,請告訴我。
謝謝
您可以使用File.exists()
檢查File是否存在。
File file = new File(filePathString);
if(file.exists()) {
//File is present
}
else{
// File is not present,Create a new one.
try {
file.createNewFile();
} catch (IOException e) {
e.printStackTrace();
}
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.