Android file Dropbox API download

I am currently working on an android application that supports android dropbox api. This works for me, so it sends the file from the android sd card to the Dropbox folder. Then I should have been able to download this file and save it again on the phoneโ€™s SD card.

How to download a file from Dropbox and save it on your device, there is very little documentation about the android api.

Thanks for any help you can provide.

0
source share
3 answers
private boolean downloadDropboxFile(String dbPath, File localFile) throws IOException{ BufferedInputStream br = null; BufferedOutputStream bw = null; try { if (!localFile.exists()) { localFile.createNewFile(); //otherwise dropbox client will fail silently } FileDownload fd = api.getFileStream("dropbox", dbPath, null); br = new BufferedInputStream(fd.is); bw = new BufferedOutputStream(new FileOutputStream(localFile)); byte[] buffer = new byte[4096]; int read; while (true) { read = br.read(buffer); if (read <= 0) { break; } bw.write(buffer, 0, read); } } finally { //in finally block: if (bw != null) { bw.close(); } if (br != null) { br.close(); } } return true; } 

Source: http://forums.dropbox.com/topic.php?id=23189&replies=5#post-159521

+4
source

if you try this link, Download the file from Dropbox and save it to SDCARD , really help to completely download any type of file using drop box

0
source
 private boolean downloadDropboxFile(String dbPath, File localFile) throws IOException{ BufferedInputStream br = null; BufferedOutputStream bw = null; try { if (!localFile.exists()) { localFile.createNewFile(); //otherwise dropbox client will fail silently } FileDownload fd = api.getFileStream("dropbox", dbPath, null); br = new BufferedInputStream(fd.is); bw = new BufferedOutputStream(new FileOutputStream(localFile)); byte[] buffer = new byte[4096]; int read; while (true) { read = br.read(buffer); if (read <= 0) { break; } bw.write(buffer, 0, read); } } finally { //in finally block: if (bw != null) { bw.close(); } if (br != null) { br.close(); } } return true; } 

It may work for you.

0
source

All Articles