Search code examples
androidandroid-4.2-jelly-bean

getExternalStorage() and MTP behavior on Jellybean


Sometimes, while I run a development version of an app, I want to export the database so I can copy it over to a desktop, view the database there and ensure it is being edited correctly.

Normally I will call Environment.getExternalStorageDirectory() and copy the database there. However, Jellybean on the Galaxy Nexus threw me for a loop--I could not see the file via MTP! (Mac OS X File Transfer). If I use Wifi File Explorer to browse the files on the device, then I see the database file.

After doing some research, I'm guessing this is due to Jellybean's simulated user-specific external storage. That would be why it tells me it's writing to /storage/emulated/0/ instead of /sdcard for example.

Is there a way to tell Android "write this file to where it is world-readable (including MTP) instead of only making it available to apps run under the same user"?


Solution

  • I had the same problem. I couldn't see a txt file I'd written in the 'Download' folder with 'Android File Transfer'. The only solution I've found is to write an extra .txt file in the same folder where you write your file, then open that folder in an app like 'Astro File Manager' and delete the extra file. Now open 'Android File Transfer', close it, and open it again. Your desired file should appear now.

    I use /storage/emulated/0/Download/ as path but it should work in any other folder.

    I know it's not the perfect solution but for now it's all I have. Hope this will work for you too!