我正在使用Firebase数据库,但是当我存储图像名称但成功存储图像时,我的应用程序崩溃了
public void Saveprofile(){
if (ImageUri!=null){
StorageReference fileReferencce=storageReference.child(System.currentTimeMillis()+"."+getFileExtension(ImageUri));
fileReferencce.putFile(ImageUri)
.addOnSuccessListener(new OnSuccessListener<UploadTask.TaskSnapshot>() {
@Override
public void onSuccess(UploadTask.TaskSnapshot taskSnapshot) {
Task<Uri> firebaseUri = taskSnapshot.getStorage().getDownloadUrl();
Toast.makeText(MainActivity.this, "Upload Succesfully", Toast.LENGTH_LONG).show();
Data data= new Data(Bname.getText().toString().trim(),firebaseUri.toString());
String id = dref.push().getKey();
dref.child(id).setValue(data);
}
})
.addOnFailureListener(new OnFailureListener() {
@Override
public void onFailure(@NonNull Exception e) {
Toast.makeText(MainActivity.this, e.getMessage(), Toast.LENGTH_LONG).show();
}
}).addOnProgressListener(new OnProgressListener<UploadTask.TaskSnapshot>() {
@Override
public void onProgress(UploadTask.TaskSnapshot taskSnapshot) {
}
});
}else {
Toast.makeText(this, "Chose image first", Toast.LENGTH_SHORT).show();
}
}