When you "connect the device to [your] machine", you do not get the root directory of the device. You will have access to external storage.
Also, getExternalStoragePublicDirectory()
does not take random values as parameters. Use something like Environment.DIRECTORY_DOWNLOADS
.
For example, here is what I see on Ubuntu 13.10 when I plug in a Nexus 7 (2013):
When I go into "Internal storage", I see:
Here is the contents of /mnt/shell/emulated/0/
, as viewed in DDMS:
You will notice that the directory listing for "Internal storage" is the same as it is for /mnt/shell/emulated/0/
. That is because they are the same directory.
For the primary user account, Environment.getExternalStorageDirectory()
points to a spot that, when viewed in DDMS, shows up as /mnt/shell/emulated/0/
and, via MTP, shows up as "Internal storage" (though the latter is the Nexus 7's name for it -- it may vary by device).
Also note that MTP may not show everything that is in /mnt/shell/emulated/0/
, because MTP is really driven by MediaStore
, and not everything may have been indexed yet. If you write files to external storage, use MediaScannerConnection
and scanFile()
to ensure that the device's end of the MTP connection knows about them.
And I apologize for the mixed "internal storage" / "external storage" terminology. I just got through writing a blog post series trying to explain all of that.
getExtranalStorageDirectory()
– Mizell