Quiero descargar un archivo pdf de una url. Para ver el archivo pdf utilicé el siguiente código:
File file = new File("/sdcard/example.pdf");
if (file.exists()) {
Uri path = Uri.fromFile(file);
Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setDataAndType(path, "application/pdf");
intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
try {
startActivity(intent);
}
catch (ActivityNotFoundException e) {
Toast.makeText(OpenPdf.this, "No Application Available to View PDF",
Toast.LENGTH_SHORT).show();
}
}
Está funcionando, pero ¿cómo obtengo el archivo pdf de una URL (por ejemplo, http: //.../example.pdf
). Quiero descargar el archivo pdf de esta url. Por favor, ayúdame. Gracias de antemano.