I download a file from firebase using file like. If I run this code on android emulator then I can see the downloaded file from file browser but in the real phone, it does not display the file.
private void DownloadFromStorage(String fileName) {
// CREATE FOLDER IF NOT EXIST
File dir = new File(DownloadActivity.this.getExternalFilesDir(null), "notes");
if (!dir.exists()) {
boolean b = dir.mkdir();
}
// CREATE FILE
File file = new File(DownloadActivity.this.getExternalFilesDir(null), fileName);
StorageReference storageReference = FirebaseStorage.getInstance().getReference()
.child("note")
.child(fileName);
Log.d("downloadFile: " ,""+ storageReference.getPath());
storageReference.getFile(file).addOnSuccessListener(new OnSuccessListener<FileDownloadTask.TaskSnapshot>() {
@Override
public void onSuccess(FileDownloadTask.TaskSnapshot taskSnapshot) {
if (getBaseContext() != null) {
txtStatus.setVisibility(View.GONE);
mProgressBar.setVisibility(View.GONE);
myToast("Download Complete.");
Log.d("downloadFile: " ,"DOWNLOAD COMPLETE");
}
}
}).addOnFailureListener(new OnFailureListener() {
@Override
public void onFailure(@NonNull Exception e) {
if (getBaseContext() != null) {
txtStatus.setVisibility(View.GONE);
mProgressBar.setVisibility(View.GONE);
myToast("Download Fail");
Log.d("downloadFile: " ,"DOWNLOAD FAIL");
}
}
}).addOnProgressListener(new OnProgressListener<FileDownloadTask.TaskSnapshot>() {
@Override
public void onProgress(@NonNull FileDownloadTask.TaskSnapshot taskSnapshot) {
double progress = (100.0 * taskSnapshot.getBytesTransferred()) / taskSnapshot.getTotalByteCount();
@SuppressLint("DefaultLocale") String uc = String.format("Downloading... %.2f ", progress);
if (getBaseContext() != null) txtStatus.setText(uc);
}
});
}
How can I see this file from the file browser?