The following code is how I am trying to identify if a file exists in the internal storage, MODE_PRIVATE
.
public boolean isset(String filename){
For internal storage, this works for me:
public boolean isFilePresent(String fileName) {
String path = getContext().getFilesDir().getAbsolutePath() + "/" + fileName;
File file = new File(path);
return file.exists();
}
Kotlin: This works for me !!
fun check(path: String?): Boolean
{
val file = File(path)
return file.exists()
}
hope this method helps you.
public boolean fileExist(String fname){
File file = getBaseContext().getFileStreamPath(fname);
return file.exists();
}