Aspsine / MultiThreadDownload

Android Multi-Thread Download library
908 stars 285 forks source link

A feature: Support for saving in application cache folder or files folder #96

Open raju249 opened 7 years ago

raju249 commented 7 years ago

Hi team, I was just wondering if we could add support for saving the downloaded data in application cache folder or application files folder so that its not accessed by any other app. Like for example a Music Streaming app can have feature for downloading songs, but would like to access by that app only and not any other music player app.

Thanks

salehmosleh commented 6 years ago

use below codes to inform to android OS " a new media added! " :

            // save file to galery
            if (fifn.isMediaFile()) {
                try {
                    File mDownloadDir = Tools.getDownloadDirectoryFile(fifn.savelocation);
                    File temp_file = new File(mDownloadDir, fifn.name);
                    MediaScannerConnection.scanFile(
                            context,
                            new String[]{temp_file.getAbsolutePath()},
                            new String[]{Tools.getMimeType(temp_file.getAbsolutePath())},
                            new MediaScannerConnection.OnScanCompletedListener() {
                                @Override
                                public void onScanCompleted(String path, Uri uri) {
                                    //....
                                }
                            }
                    );
                } catch (Exception e) {
                    e.printStackTrace();
                }
            }