I will suggest you to upload image and text by using below method.
In UpdateSettings function, create an Item class.
private void UpdateSettings() {
String setUserName = userName.getText().toString();
String setStatus = userStatus.getText().toString();
if (TextUtils.isEmpty(setUserName)) {
Toast.makeText(this, "Please enter your user name...", Toast.LENGTH_SHORT).show();
}
if (TextUtils.isEmpty(setStatus)) {
Toast.makeText(this, "Please write your status...", Toast.LENGTH_SHORT).show();
} else {
Item item =new Item();
if(resultUri!=null) {
item = new Item(resultUri.toString(), setUserName, setStatus, currentUserID);
}else{
item = new Item(retrieveProfileImage, setUserName, setStatus, currentUserID);
}
RootRef.setValue(item).addOnCompleteListener(new OnCompleteListener<Void>() {
@Override
public void onComplete(@NonNull Task<Void> task) {
if (task.isSuccessful()) {
SendUserToMainActivity();
Toast.makeText(SettingsActivity.this, "Profile Updated Successfully", Toast.LENGTH_SHORT).show();
} else {
String message = task.getException().toString();
Toast.makeText(SettingsActivity.this, "Error:", Toast.LENGTH_SHORT).show();
}
}
});
}
}
Noted that I am passing the Uri to firebase. So when you want to retrieve, you will get a valid url.
Item
package com.example.chatterbox;
public class Item {
String image;
String name;
public String getImage() {
return image;
}
public void setImage(String image) {
this.image = image;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getStatus() {
return status;
}
public void setStatus(String status) {
this.status = status;
}
public String getUid() {
return uid;
}
public void setUid(String uid) {
this.uid = uid;
}
String status;
String uid;
public Item(String resultUri, String setUserName, String setStatus, String currentUserID) {
this.image = resultUri;
this.name = setUserName;
this.status = setStatus;
this.uid = currentUserID;
}
public Item() {
}
}