My query is almost similar to one asked in the following link :
How to get file name when clicking on URL in webview
I don't want to use URLUtil for the reasons mentioned there.
Also, getting the file name using Content-Disposition header field does not work in my case.
I am using Android DownloadManager API for downloading file/images. I have to set destination filename using setDestinationInExternalPublicDir (String dirType, String subPath) method.
I have observed that DownloadManager provide name such as "downloadfile.jpeg", "downloadfile-2.jpeg" when any image url is used. I have looked into the DownloadManager source code and found COLUMN_LOCAL_FILENAME and COLUMN_TITLE that might be storing the name of file.
How can I get the file/image name as done in DownloadManager API ?
If not, is there any way I can detect that these urls does not contain filename at the end so that I can provide my custom name ?
Asked
Active
Viewed 1,245 times
1

Community
- 1
- 1

r.bhardwaj
- 1,603
- 6
- 28
- 54
-
Hi please check this answer hope you'll getting help from this http://stackoverflow.com/a/13322285/760489 – Pratik Jul 08 '14 at 05:25
-
1No it won't help me because that solution will provide the file name after the completion of download. Instead I want the file name prior to download so that I can save the file with my custom file name. – r.bhardwaj Jul 09 '14 at 05:18
-
Also, I could not use approaches of URLUtil and Content-Disposition header for getting file name that I have already mentioned in the question. – r.bhardwaj Jul 09 '14 at 05:22