Trying to open pdf file from download folder on device,
i save the name of file in firebase
and now i want to check if the file is already found on device and then open it else download from firebase
.
File file = new File(Environment.getExternalStorageDirectory() + "filename");
System.out.println(Environment.getExternalStorageDirectory());
///but when i print Environment.getExternalStorageDirectory() i get
///storage/emulated/0
if (file.exists()) {
System.out.println(file.getAbsoluteFile());
Intent target = new Intent(Intent.ACTION_VIEW);
target.setDataAndType(Uri.fromFile(file), "application/pdf");
target = Intent.createChooser(target, "Open File");
target.setFlags(Intent.FLAG_ACTIVITY_NO_HISTORY);
Intent intent = Intent.createChooser(target, "Open File");
try {
startActivity(intent);
} catch (ActivityNotFoundException e) {
e.printStackTrace();
}
} else {
System.out.println("file not found");
}