Reputation: 298
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
Upvotes: 0
Views: 239
Reputation: 4470
Please follow below samples available in stackoverflow
I think above links may help
Upvotes: 1
Reputation: 4547
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();
}
}
Upvotes: 1