0

I tried to make a directory dynamically using mkdirs() and it created sucessfully the directory and copied the files to the created directory. It's possible to see the new directory in the tablet (xoom) but when I connect to my PC to copy some files the directory does not appear.

what can i do?

EDT: This is what i've done:

File dirs = new File(Environment.getExternalStorageDirectory()+"/MyDir/");
    dirs.mkdirs();

What is wrong?

EDT2: I have tried everything in this thread (http://stackoverflow.com/questions/6218572/creating-a-folder-programmatically-on-a-xoom) and didn't work. Suggestions?

PS: I found an app which re-scan de sdcard. If i create the directory and use this app, it works perfecly. anyone knows how to re-scan sdcard?

JannGabriel
  • 302
  • 5
  • 14
  • You need to save the file/directory on SD Card to be visible on the PC, not on the app data folder. – Marcio Covre Aug 27 '12 at 19:21
  • if I restart my xoom, connect it again to PC, disconnect and than connect again.. tha folder appears. Anyone know how to make it works? PLEAAASSE? – JannGabriel Aug 31 '12 at 12:10

3 Answers3

1

I have solved this problem by executing the following line, which has been recommended in the answer above, as well as in https://stackoverflow.com/a/8606529/2482894

sendBroadcast(new Intent(Intent.ACTION_MEDIA_MOUNTED,
Uri.parse("file://" + Environment.getExternalStorageDirectory())));
Community
  • 1
  • 1
leo9r
  • 2,037
  • 26
  • 30
1

Quite an old post but thought to add the answer which does not required addition URI.

// initiate media scan and put the new things into the path array to
// make the scanner aware of the location and the files you want to see
MediaScannerConnection.scanFile(context, new String[] {filePath}, null, null);
Android
  • 3,828
  • 9
  • 46
  • 79
0

Some tablets ( I think xoom is included) that has an internal memory and an SD card have different way of storing files. The getExternalStorage points to the folder /mnt/SDCard, but this is the internal memory, to get to the SDCard the path is /mnt/SDCard/SDCard (strange I know).

So you need to see the real mount of the SDCard on your tablet and see the value of Environment.getExternalStorageDirectory(), otherwise you won't be saving on the SDCard but in the tablet file-system.

EDIT: This is probably then a problem with the media driver of xoom, it should scan the sdcard when user mounts on the PC.

To rescan the sdcard you can dismount and mount, use Gallery application to refresh the SD card or programmatically calling sendBroadcast(new Intent(Intent.ACTION_MEDIA_MOUNTED, Uri.parse("file://" + Environment.getExternalStorageDirectory().getAbsolutePath())));

Marcio Covre
  • 4,556
  • 2
  • 22
  • 24
  • Hmm. my tablet has it at /mnt/externalSD (it may be externSD or extSD - going off memory here). The internal storage is at /mnt/sdcard. – Drake Clarris Aug 27 '12 at 19:47
  • Maybe on JB they fixed this, but on HoneyComb the folders were like that. – Marcio Covre Aug 27 '12 at 19:56
  • the thing is.. I created by PC an folder and then I created another one dynamically. When I search for folders in the tablet, both directorys are at the same place, but when I search from my PC, just shows the one I created first but not the one created dynamically – JannGabriel Aug 28 '12 at 13:19