We’re Still Here to Help (Even Over the Holidays!) - find out more here.
Forum Discussion
Nicolas L.
11 years agoNew member | Level 1
Download file from Dropbox to local android Java
I spent some days on this code without finding the solution. Could you help me please?
I want to download a file from a Dropbox account to the application storage (local memory). When I open the f...
Steve M.
Dropbox Staff
11 years agoIn general, to download a file, you need to open it and hold it open while waiting for the download to complete. (Everything in the Sync SDK is asynchronous.)
So the usual pattern here is to open the file, register a listener on that file, wait for getNewerStatus().isCached to be true, and then call update() on the file. At that point, you should be able to read the latest file contents. (If you read before that, you'll either see cached data if available or you'll perhaps hang the UI thread waiting for network I/O.)
I would actually expect your original code to work (but hang the thread), since getReadStream() should block if there's no cached data.
Can you confirm that after dst.transferFrom(src, 0, src.size());, the file is empty (or there is some other problem with it) to narrow down the issue?
About Dropbox API Support & Feedback
Find help with the Dropbox API from other developers.
The Dropbox Community team is active from Monday to Friday. We try to respond to you as soon as we can, usually within 2 hours.
If you need more help you can view your support options (expected response time for an email or ticket is 24 hours), or contact us on X, Facebook or Instagram.
For more info on available support options for your Dropbox plan, see this article.
If you found the answer to your question in this Community thread, please 'like' the post to say thanks and to let us know it was useful!