0

enter image description herei uploaded some files in a storage reference in firebase and i want display those files in listview to let the user choose the specific file and download it . files of type word or powerpoint etc.. here is the code for uploading :

    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");
    }
}

But i cant find a proper code for listing the files here is a screenshot from the storage :

Pardon a newbie

hisham sherif
  • 57
  • 1
  • 5
  • There is no public API in the Cloud Storage for Firebase SDK to list files. You will have to store the list elsewhere, such as for example in the Firebase Database. See http://stackoverflow.com/questions/37335102/how-to-get-an-array-with-all-pictures – Frank van Puffelen May 02 '17 at 13:35
  • Aha I managed to get the url and save it in firebase database , thank you so much . – hisham sherif May 03 '17 at 00:30

0 Answers0