Most of the times it is not required to do the full sync with a Dropbox acccount, but you just want to download a single public file or folder.
I have a map application where users can add their own data files. If they have their own Dropbox account they can do it comfortably through my app.
Here is a rough cookbook how I proceed in my app, it may be helpful for others:
Public file or folder access can be created from the user's Dropbox account webpage (long URLs) or the Dropbox Android app (shortened URLs).
I find the shortened URLs very convenient, as they can be entered easily into an editview by the user and download can be initiated from there.
In your app:
- Open the Android app and go to the file or folder you want to be published. - Select "Publish" and then your e-mail account as destination.
- Your mail app will open, then just write down the shortened URL http://db.tt/.... as it appears. You do not need to send the mail! Just close your mail app again
- In your Dropbox web interface check that the file or folder was published under "LINKS".
The file or folder link has a different long URL, that needs to be called, when download shall be initiated directly, i.e. without going manually through the Dropbox web interface. That is what you want in your app.
- from your app now call the web interface by an http call, i.e. "http://db.tt/ABCDEFG" (do not use webview, just http)
- capture the http response to a string and parse the string with indexof and indexof2 for
"/s/" until next "QUOTE" for files
"/sh/" until next "QUOTE" for folders
- add "https://www.dropbox.com/" BEFORE the parsed string
- add "/?dl=1" AFTER the parsed string
- this makes up the download URL
- now download the file or folder from this URL
If you have addressed a folder, this will be downloaded as zip file including all files and folders it may contain. The root folder in the zip file has the same name as the folder you have addressed for download. Unzipping of the file can be done by the ABZipUnzip library.
Voila
:icon_clap:
I have a map application where users can add their own data files. If they have their own Dropbox account they can do it comfortably through my app.
Here is a rough cookbook how I proceed in my app, it may be helpful for others:
Public file or folder access can be created from the user's Dropbox account webpage (long URLs) or the Dropbox Android app (shortened URLs).
I find the shortened URLs very convenient, as they can be entered easily into an editview by the user and download can be initiated from there.
In your app:
- Open the Android app and go to the file or folder you want to be published. - Select "Publish" and then your e-mail account as destination.
- Your mail app will open, then just write down the shortened URL http://db.tt/.... as it appears. You do not need to send the mail! Just close your mail app again
- In your Dropbox web interface check that the file or folder was published under "LINKS".
The file or folder link has a different long URL, that needs to be called, when download shall be initiated directly, i.e. without going manually through the Dropbox web interface. That is what you want in your app.
- from your app now call the web interface by an http call, i.e. "http://db.tt/ABCDEFG" (do not use webview, just http)
- capture the http response to a string and parse the string with indexof and indexof2 for
"/s/" until next "QUOTE" for files
"/sh/" until next "QUOTE" for folders
- add "https://www.dropbox.com/" BEFORE the parsed string
- add "/?dl=1" AFTER the parsed string
- this makes up the download URL
- now download the file or folder from this URL
If you have addressed a folder, this will be downloaded as zip file including all files and folders it may contain. The root folder in the zip file has the same name as the folder you have addressed for download. Unzipping of the file can be done by the ABZipUnzip library.
Voila
:icon_clap: