enter image description here我在firebase的存储引用中上传了一些文件,我希望在listview中显示这些文件,让用户选择特定文件并下载。 word或powerpoint等文件。 这是上传代码:
if (filePath != null) {
//displaying a progress dialog while upload is going on
final ProgressDialog progressDialog = new ProgressDialog(getActivity());
progressDialog.setTitle("Uploading");
progressDialog.show();
mStorageRef = FirebaseStorage.getInstance().getReference();
mStorageRef= mStorageRef.child(Coursename +"/"+ filename);
mStorageRef.putFile(filePath)
.addOnSuccessListener(new OnSuccessListener<UploadTask.TaskSnapshot>() {
@Override
public void onSuccess(UploadTask.TaskSnapshot taskSnapshot) {
//if the upload is successfull
//hiding the progress dialog
progressDialog.dismiss();
//and displaying a success toast
Toast.makeText(getActivity(), "File Uploaded ", Toast.LENGTH_LONG).show();
}
})
.addOnFailureListener(new OnFailureListener() {
@Override
public void onFailure(@NonNull Exception exception) {
//if the upload is not successfull
//hiding the progress dialog
progressDialog.dismiss();
//and displaying error message
Toast.makeText(getActivity(), exception.getMessage(), Toast.LENGTH_LONG).show();
}
})
.addOnProgressListener(new OnProgressListener<UploadTask.TaskSnapshot>() {
@Override
@SuppressWarnings("VisibleForTests")
public void onProgress(UploadTask.TaskSnapshot taskSnapshot) {
//calculating progress percentage
double progress = (100.0 * taskSnapshot.getBytesTransferred()) / taskSnapshot.getTotalByteCount();
//displaying percentage in progress dialog
progressDialog.setMessage("Uploaded " + ((int) progress) + "%...");
}
});
}
//if there is not any file
else {
//you can display an error toast
Log.i("errorMessage","Error");
}
}
但是我无法找到列出文件的正确代码 这是存储的截图:
原谅新手