Descargue el archivo desde Dropbox y guárdelo en SDCARD
Estoy realmente frustated ahora .. Quiero descargar un archivo de Dropbox y guardar ese archivo en SDCARD .. y tengo el código como:
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;
}
- Integre Dropbox en la aplicación Android, pero sin iniciar sesión
- Android Studio + dropbox-android-sync-sdk-1.1.2
- Enumera todas las carpetas y archivos de Dropbox con Dropbox API
- Permitir que la API de Dropbox acceda a mi cuenta en el dispositivo del usuario
- Sincronización de archivos y bases de datos de Android con Dropbox
Aquí estoy recibiendo un error en br = new BufferedInputStream line..Pls help
- Introducción a DropboxAPI, clase no encontrada
- Dropbox SDK para Android: no puede encontrar AndroidAuthSession
- ¿Cómo autenticar varias cuentas en Android dropbox sdk 1.5.1?
- Integrar el dropbox en mi aplicación que muestra la alerta de seguridad
- Obtener nombres de archivo de la carpeta particular de Dropbox en ArrayList
- Dropbox no se ve en la implementación del marco de acceso de almacenamiento
- Dropbox api en android
- Cómo hacer una copia de seguridad / restaurar la base de datos SQLite en Android a Dropbox
Encontré el camino:
File file= new File("/sdcard/New_csv_file.csv"); OutputStream out= null; boolean result=false; try { out = new BufferedOutputStream(new FileOutputStream(file)); } catch (FileNotFoundException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } try { DropboxFileInfo info = mApi.getFile("/photos/New_csv_file.csv", null, out, null); Log.i("DbExampleLog", "The file's rev is: " + info.getMetadata().rev); Intent JumpToParseCSV=new Intent(context,ParseCSV.class); JumpToParseCSV.putExtra("FileName", file.getAbsolutePath()); Log.i("path", "FileName"+ file.getAbsolutePath()); ((Activity) context).finish(); context.startActivity(JumpToParseCSV); result=true; } catch (DropboxException e) { Log.e("DbExampleLog", "Something went wrong while downloading."); file.delete(); result=false; } return result;
Gracias a todos….