0

I'm developping an Android app. This app generates a file on the \sdcard\ folder , but when I want to take it from the computer , i can't get it. The files appears on my device with Cabinet , but not on the computer. What is the problem ?

Thanks for your answer.

EDIT : I run my app on a Nexus 7 with KitKat 4.4.4 build.

Ideor
  • 5
  • 5
  • reconnect your device to your pc – Boe-Dev Apr 29 '15 at 08:24
  • I tried , but it doesn't work , when i create a folder from my device, it doesn't appear too. But I create a file or a folder in my device from the computer , it appears on the device file explorer. – Ideor Apr 29 '15 at 08:31
  • The file will also not shown after you reconnect you device? – Boe-Dev Apr 29 '15 at 11:37
  • Nope , after that , i reboot the device , and it seems to work now , i can see the file , but if i create another one , i can't see it , i have to reboot each time i create a file. – Ideor Apr 29 '15 at 12:15

1 Answers1

0

Please try this code.

sendBroadcast(new Intent(Intent.ACTION_MEDIA_MOUNTED,
Uri.parse("file://" + Environment.getExternalStorageDirectory())));
Boe-Dev
  • 1,585
  • 2
  • 14
  • 26
  • Starting from Android 4.4, only System apps can now use it. I use Nexus 7 (2013) with 4.4.4 for my development. – Ideor Apr 29 '15 at 14:33
  • Invoking the media scanner is what needs to happen, this was just a simple trick for doing it – Chris Stratton Apr 29 '15 at 14:36
  • See http://stackoverflow.com/questions/13270789/how-to-run-media-scanner-in-android for an example of invoking it on a specific file – Chris Stratton Apr 29 '15 at 14:38