0

I'm trying to save an html file in the Download folder, I can save without problems, but I can not see it in the Downloads Android application, I tried to find some way to display the file in the application, but have not found how. I'm saving this way:

File Download = 
   Environment.getExternalStoragePublicDirectory
   (Environment.DIRECTORY_DOWNLOADS);

File mapsDir = new File(Download, getString(R.string.folder_name));
boolean dirCreat = mapsDir.mkdir();

...
File file = new File(mapsDir,getString(R.string.file_name));
...
byte [] htmlByte=html.getBytes();
BufferedOutputStream bos = new BufferedOutputStream(new FileOutputStream(file));
bos.write(htmlByte);
bos.flush();
bos.close();

Intent intent =
       new Intent(Intent.ACTION_MEDIA_SCANNER_SCAN_FILE);
intent.setData(Uri.fromFile(file));
        context.sendBroadcast(intent);

I saw this: Android DownloadManager save to Download folder

But I can't apply this to my problem

I know that the file is saved as through the Astro app I can view it.

And I need to show the file in this App.

I am using a nexus 4 with android 4.4.

Thanks to anyone who can help.

Community
  • 1
  • 1
  • You have to invoke the mediascanner on the new file. But i'm not quite sure. The Downloads app maybe only shows what it downloaded itself instead of displaying the whole directory. – greenapps Aug 08 '14 at 17:04
  • http://stackoverflow.com/questions/4646913/android-how-to-use-mediascannerconnection-scanfile – greenapps Aug 08 '14 at 17:09
  • @greenapps I tried your suggestion but didn't work , the app still doesn't show the file – Rafael Carvalho Aug 12 '14 at 12:52

0 Answers0