Android Question [SOLVED] Can't see download files in download dir.

Q Candiani

Member
Licensed User
Longtime User
Hello, I am using the Dropbox API to download files. It works fine: it downloads files correctly in destination folder. But, when I download files to File.Combine (File.DirRootExternal, "Download") I can only find these files in Downloads using File Explorer. If I open the shortcut "Downloads" on the menu, it doesn't show these files.

I have read the forums looking for a possible answer, but couldn't find any similar problem. Some help?

Thanks

File explorer shows the file. Download does not.
 

Q Candiani

Member
Licensed User
Longtime User
DonManfred, thanks for answer quickly. Effectively I use rp.CheckAndRequest (rp.PERMISSION_WRITE_EXTERNAL_STORAGE). But the problem is not within my code. I have no problem there. If I try to open the donwload file after downloading it from my app, I can open using Intent with no problems.
The problem is "outside" of my application. I can't see the file in the "Download" shortcut. But, in File Explorer, Donwload Dir, I can see it. I can't think what the problem is.
 
Upvote 0

emexes

Expert
Licensed User
download files to File.Combine (File.DirRootExternal, "Download") I can only find these files in Downloads using File Explorer. If I open the shortcut "Downloads" on the menu
1/ Download or Downloads?

2/ If you copy a small test file to the window opened by shortcut "Downloads" on the menu, which directory (full path) does that file end up in?
 
Upvote 0

Q Candiani

Member
Licensed User
Longtime User
Hi Emexes,

I have verified the full path and in both cases it is the same: 'storage/emulated/0/download'

I attach two screenshots:

One of them shows file storage in 'storage/emulated/0/Download' using File Explorer. The other shows the window opened by the "Downloads" shortcut. It only shows a file downloaded from Drive. But it doesn't show the other three files downloaded from my app.
I have noticed that if I rename a file in 'storage/emulated/0/Download' using File Explorer, this change is not shown in the window opened by the "Downloads" shortcut. So I think the window opened by the "Downloads" shortcut is not a directory but rather a gallery of shortcuts (?)

But, I need to show downloaded files from my app in this window opened by the "Downloads" shortcut.

 
Upvote 0

JohnC

Expert
Licensed User
Longtime User
As a test, try rebooting the device and see if the "Downloads" shortcut app now shows the files you programmically placed there.

I'm thinking that the downloads app might only show files that it "downloaded" and wont show files placed there by another app. But maybe restarting the Download manager service/app might force a refresh to the list of files it displays.

Otherwise, you may have to place files in the download directory using a call to the download manager as @emexes found the code at stackoverflow in order to get the downloads app to list those files.
 
Upvote 0

Q Candiani

Member
Licensed User
Longtime User
Thank you very much! You are all great!

In my case, the DownloadManager library was the key. With AddCompletedDownload I was able to "show" the downloaded files in Downloads.

In my opinion, this issue was solved. Thanks again.

This is an excerpt from the Dropbox HttpJob code. I have created a map_mime_types map with practically all the mime_types that my users could download in the future.
I took the mime_types from here.



AddCompletedDownload:
Sub JobDone(Job As HttpJob)
    Private mCallback As Object
    Private mEvent As String
    Private mDebug As Boolean: mDebug = True
    job_success = Job.success

    If Job.Success Then
        Dim res As String
        res=Job.GetString
        Select Job.JobName
            Case "filedownload"
                Dim OutStream As OutputStream
                Dim pth As String = GetPath(Job.Tag)
                Dim fle As String = GetFilename(Job.Tag)
                Dim name As String
                Log("DownloadReady: "&Job.Tag)
                Log("DestPath: "&pth)
                'Where pth = File.Combine(File.DirRootExternal, "Download")
                LogColor("DestFilename: "&fle,Colors.cyan)
                OutStream = File.OpenOutput(pth, fle, False) ' Job.Tag is read to set the Original Filename we specify earlier in the creation of the Job
                File. Copy2(Job.GetInputStream,OutStream) ' save the file
                OutStream.Close
                Dim dm As DownloadManager
                Try
                    Dim extension As String = fle.SubString2(fle.LastIndexOf("."), fle.Length)
                    Log("extension: " & extension)
                    If Starter.map_mime_types.get(extension) <> Null Then
                        Dim application_mime As String = Starter.map_mime_types.get(extension)
                    Else
                        Dim application_mime As String = "application/" + extension
                    End If
                    Log("application_mime:" & application_mime)
                    dm.AddCompletedDownload(fle, file_type_name , True , application_mime ,File.Combine(pth,fle),File.Size(pth,fle),True)
                Catch
                    Dim error_info As String = "serv_dropbox downloadManager: application_mime"  & application_mime & " - [Error]: " &  Job.ErrorMessage
                    LogColor(error_info , Colors.argb(196, 255, 140, 0))
                End Try
        End Select
    Else
        LogColor("Error: "  & Job.ErrorMessage,Colors.Red)
    End If
    CallSubDelayed(Me, "job_done_complete")
End Sub
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…