3

I created an android application in which it creates a folder that stores data, but I want it to be shown right away in windows when the usb is connected. right now, it can only be seen after i restarted the mobile device or mount and unmounted the sdcard. or is there even a way to mount and unmount the device programmatically?

someone recommends me this snippet sendBroadcast(new Intent(Intent.ACTION_MEDIA_MOUNTED, Uri.parse("file://" + Environment.getExternalStorageDirectory())));

but i can't seem to understand how to apply this code or if this is even applicable with my concern.

She Smile GM
  • 1,322
  • 1
  • 11
  • 33
  • [This](http://android-er.blogspot.in/2010/10/how-to-create-sub-folder-in-sd-card.html) link will surely help you... Let me know if you still have the problem.... – Gautam Mandsorwale Sep 18 '12 at 10:07
  • thanks for the link but that's what i have right now. my problem is it can't be shown in windows right away not until sdcard in mounted and unmounted. – She Smile GM Sep 18 '12 at 10:22
  • Hmmm...For now you can take the user to the device's built-in Settings, till we can find your suitable solution.. `Intent i = new Intent(android.provider.Settings.ACTION_MEMORY_CARD_SETTINGS); startActivity(i);` – Gautam Mandsorwale Sep 18 '12 at 11:06

1 Answers1

0

You need to launch a scan on the new files so that they can be seen from outside. See this answer

// 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(this, new String[] {path.toString()}, null, null);

PS: This question is a bit old but it is the first one I found when I got stuck... So, probably worth answering for the next ones !

Alexis R
  • 91
  • 1
  • 7