diff --git a/app/src/main/java/gallery/memories/NativeX.java b/app/src/main/java/gallery/memories/NativeX.java index d353b39c..71062b92 100644 --- a/app/src/main/java/gallery/memories/NativeX.java +++ b/app/src/main/java/gallery/memories/NativeX.java @@ -88,7 +88,7 @@ public class NativeX { } @JavascriptInterface - public void downloadFromUrl(final String url) { + public void downloadFromUrl(final String url, final String filename) { Uri uri = Uri.parse(url); DownloadManager manager = (DownloadManager) mActivity.getSystemService(Context.DOWNLOAD_SERVICE); DownloadManager.Request request = new DownloadManager.Request(uri); @@ -98,6 +98,9 @@ public class NativeX { String cookies = android.webkit.CookieManager.getInstance().getCookie(url); request.addRequestHeader("cookie", cookies); + // Save the file to external storage + request.setDestinationInExternalPublicDir(android.os.Environment.DIRECTORY_DOWNLOADS, "memories/" + filename); + // Start the download manager.enqueue(request); }