How can I come to know that any file is exist or not in Android sdcard or internal storage?
Case : we don't have exact location directory. I want to check that file in any directory.
If there is any method or any example to do so please let me know.
Thank you
You can check whether File exists or not by using File.exists()
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();
}
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.