[英]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.