Reputation: 3
I would like that the users of my Android application be able to copy data files to their computer via USB. They should additionaly be able to erase the files on the android device once copied. To this end, my application creates .csv files which are stored in the external storage space, as recommended by Google. I have created the destination folder thanks to this method:
static File getMyStorageDir() {
File file = newFile(Environment.getExternalStoragePublicDirectory(
Environment.DIRECTORY_DOCUMENTS), "MyDir");
if (!file.mkdirs()) {
Log.e( "LogFile", "Directory not created");
}
return file;
}
On the Android device I can browse the .csv files in "/sdcard/Documents/MyDir". When I connect the device to a Win 10 computer in MTP mode, the "Documents" folder does not appear. If I try to create the "Documents" folder in the Windows explorer, it will fail, (probably) proving that the folder exists, but is hidden. On the other hand I can create a folder "foo" in Windows and put files into it. The "foo" folder and its content will appear in the browser (ES File Explorer) on the device after a while. To finish, I can erase files in the "DCIM/Camera" folder...
I think I am close but I am missing something...
Upvotes: 0
Views: 475
Reputation: 965
The MTP cache gets out of date until a reboot of the phone.
A workaround is:
Clear the "Media Storage" app's data and restart the device
Upvotes: 2