0

Assume a device running Marshmallow (API 23), my app uses

getExternalFilesDir(Environment.DIRECTORY_DOCUMENTS)

and the path displayed on the device (in a user screen) is:

/storage/emulated/0/Android/data/<app>/files/Documents/<mydir>/<myfile>

and the user-created files exist in that directory.

When I go to Windows Explorer (with device connected as USB), I see:

<mount point>\Card\Android\data\<app>\files\Documents

and that directory is empty!

What I'm trying to accomplish seems simple enough:

Allow user to save a file which is then accessible via PC when connected as USB device, located in a consistent and intuitively obvious path (such as the noted mount point).

Yet, obviously there is a disconnect somewhere so I'm seeking help.

Just to add to the confusion, when running an emulator at API 19, the same function returns

/storage/sdcard/Android/data/<app>/files/Documents/<dir>/myfile.xml

Finally, it would be super if the expected behavior is the same no matter which device level - so, for example, documentation can be accurate as to what to expect on the device screen and on the Windows explorer.

  • Any reason you want to write into `Android/data/`? Have you tried picking a different location? – OneCricketeer Feb 05 '17 at 18:29
  • https://stackoverflow.com/questions/32789157/how-to-write-files-to-external-public-storage-in-android-so-that-they-are-visibl – CommonsWare Feb 05 '17 at 18:30
  • @cricket_007 I was hoping to stick with whatever the platform returns as in getExternalFilesDir() or one of the half-dozen similar functions. Looks like @ CommonsWare provided an interesting complexion to the problem - I'll add the media scanner thing and post back. –  Feb 05 '17 at 18:44

0 Answers0