 private void addToCloudStorage() { File f = new File(pictureFilePath); Uri picUri = Uri.fromFile(f); final String cloudFilePath = deviceIdentifier + picUri.getLastPathSegment(); FirebaseStorage firebaseStorage = FirebaseStorage.getInstance(); StorageReference storageRef = firebaseStorage.getReference(); StorageReference uploadeRef = storageRef.child(cloudFilePath); uploadeRef.putFile(picUri).addOnFailureListener(new OnFailureListener(){ public void onFailure(@NonNull Exception exception){ Log.e(TAG,"Failed to upload picture to cloud storage"); } }).addOnSuccessListener(new OnSuccessListener<UploadTask.TaskSnapshot>(){ @Override public void onSuccess(UploadTask.TaskSnapshot taskSnapshot){ Toast.makeText(CapturePictureActivity.this, "Image has been uploaded to cloud storage", Toast.LENGTH_SHORT).show(); } }); } 