Skip to content Skip to sidebar Skip to footer

Why Does My File Not Exist Even When I Gave It A Path That Exist?

My if condition on imgFile.exist() is giving me false, but I can see the file exist in the path when Log.d prints its result out. I'm simply trying to load an image from a path to

Solution 1:

Add this in your manifest.

<uses-permissionandroid:name="android.permission.WRITE_EXTERNAL_STORAGE" /><uses-permissionandroid:name="android.permission.READ_EXTERNAL_STORAGE" />

Solution 2:

What is your SDK value in gradle? If it is 23 then you need to ask for permission at run time.

http://developer.android.com/training/permissions/requesting.html

Solution 3:

try this instead of imgFile.exists()

Filefile=newFile(path);
if (!file.isFile()) {
    //your code
}else{
//your code
}

Post a Comment for "Why Does My File Not Exist Even When I Gave It A Path That Exist?"