I want to add an image plus the following attributes, names, category, phone, address, etc in the storage firebase, I already have the registration and the insertion of an attribute but I do not know how to save the following attributes to my firebase. This is my code.
if (imgUri != null) {
final ProgressDialog dialog = new ProgressDialog(this);
dialog.setTitle("registrando imagen");
dialog.show();
//Get the storage reference
StorageReference ref = mStorageRef.child(FB_STORAGE_PATH + System.currentTimeMillis() + "." + getImageExt(imgUri));
//Add file to reference
ref.putFile(imgUri).addOnSuccessListener(new OnSuccessListener<UploadTask.TaskSnapshot>() {
@Override
public void onSuccess(UploadTask.TaskSnapshot taskSnapshot) {
String nombreRest=nombre.getText().toString();
String telefono= numero.getText().toString();
String description2= direccion.getText().toString();
Restaurante imageUpload = new Restaurante(nombreRest,taskSnapshot.getDownloadUrl().toString());
//Save image info in to firebase database
String uploadId = mDatabaseRef.push().getKey();
mDatabaseRef.child(nombreRest).setValue(imageUpload);
mDatabaseRef.child("Telefono").setValue(telefono);
mDatabaseRef.child("categoria").setValue(cate);
mDatabaseRef.child("horario").setValue(horario2);
mDatabaseRef.child("direccion").setValue(description2);
//Dimiss dialog when success
dialog.dismiss();
//Display success toast msg
Toast.makeText(getApplicationContext(), "Imagen registrada", Toast.LENGTH_SHORT).show();
}
})
.addOnFailureListener(new OnFailureListener() {
@Override
public void onFailure(@NonNull Exception e) {
//Dimiss dialog when error
dialog.dismiss();
//Display err toast msg
Toast.makeText(getApplicationContext(), e.getMessage(), Toast.LENGTH_SHORT).show();
}
})
.addOnProgressListener(new OnProgressListener<UploadTask.TaskSnapshot>() {
@Override
public void onProgress(UploadTask.TaskSnapshot taskSnapshot) {
//Show upload progress
double progress = (100 * taskSnapshot.getBytesTransferred()) / taskSnapshot.getTotalByteCount();
dialog.setMessage("Uploaded " + (int) progress + "%");
}
});
} else {
Toast.makeText(getApplicationContext(), "Please select image", Toast.LENGTH_SHORT).show();
}
here I leave a photo to understand me