Please any one please help. This is My API method
@POST(\"/user/new.json\")
Call createUser(@Body User user);
This is my call in Main
Retrofit to post data.There is Way to Saving data in Firebase. May you know that Firebase managing all the thing in background itself.
I don't know why are you posting data using Retrofit.
Snippet to send and update automatically.
public class User {
private int birthYear;
private String fullName;
public User() {}
public User(String fullName, int birthYear) {
this.fullName = fullName;
this.birthYear = birthYear;
}
public long getBirthYear() {
return birthYear;
}
public String getFullName() {
return fullName;
}
}
Firebase alanRef = ref.child("users").child("alanisawesome");
User alan = new User("Alan Turing", 1912);
alanRef.setValue(alan);
You can also save data directly to a database location:
//Referencing the child node using a .child() on it's parent node alansRef.child("fullName").setValue("Alan Turing"); alansRef.child("birthYear").setValue(1912);
It will save as you want:
{
"users": {
"alanisawesome": {
"birthYear": "1912",
"fullName": "Alan Turing"
}
}
}
Please follow the docs: Saving Data in Firebase
Thank you.