Problem with getting directory to appear over USB

  • Replies:1
  • OpenNot stickiedUnanswered
  • Forum posts: 13

Apr 18, 2016, 7:25:10 AM via Website

I'm using a USB connection to copy files from my Android phone to my PC, that are saved with this app I'm making. I found a workaround for when files aren't appearing. I just do:
MediaScannerConnection.scanFile(this, new String[]{MyFile.getAbsolutePath()}, null, null);
and then the file appears.

However I'm having much more trouble getting DIRECTORIES to appear over USB. When I use MyDirectory.mkdirs() to make a directory based on a complete path, and then follow that up with this code to try to force it to be visible:
MediaScannerConnection.scanFile(this, new String[]{MyDirectory.getAbsolutePath()}, null, null);
it does become visible over the USB connection on my PC, but it does NOT appear as a directory. Instead it appears as an extensionless file. I have searched long and hard all over the net, for about an hour, trying to find a solution to this problem, but it seems that nobody else has experienced this exact problem (or else my Googling skills aren't good enough, or else my Android programming skills are really bad).

Giving up hope of finding a solution elsewhere, I have turned to this fourm. I hope somebody here can provide me with an answer.

— modified on Apr 18, 2016, 7:26:33 AM

  • Forum posts: 13

Apr 20, 2016, 8:24:22 PM via Website

Sorry to have to bump this thread, but it's almost scrolled off the bottom of the page, and I need an answer to this, in order to be able to finish the app I'm working on. My app MUST be able to create a folder/directory, that is visible not only to the phone on which the app is installed, but also a PC when connected to the PC with a USB cable.

Recommended by NextPit