File Does Exists When Calling .exists() But Can't Find It Later
I'm trying to create a file that is eventually going to hold a picture (EXTRA_OUTPUT) like this: File mediaStorageDir = new File(Environment.getExternalStoragePublicDirectory(
Solution 1:
The mediaStorageDir.exists() returns true, but I can't find the folder in windows.
Probably that is because MediaStore
does not know about the directory, and so the MTP connection to Windows does not know about the directory. You can try using MediaScannerConnection
and scanFile()
to resolve this, though I have only tried that for files, not directories. Also, even after indexing, you may need to do "Refresh" from your Explorer window, or disconnect/reconnect the device, as Windows may cache the MTP results and not detect a change even if Android knows about it.
Post a Comment for "File Does Exists When Calling .exists() But Can't Find It Later"