So, I recently learn about firebase database, and now i'm able to insert a data. I have this script which is to store data to my firebase .
mDatabase = FirebaseDatabase.getInstance().getReference("Biodata");
String userId = mDatabase.push().getKey();
Biodata bio = new Biodata("MyUser", "MyUser@email.com");
mDatabase.child(userId).setValue(bio);
The script above is in oncreate
, so when i run the activty again and again the data will insert twice or more
and here is my firebase
Biodata
-LAuyJho4kTnJt5WuCtJ
Email: "MyUser@email.com"
Fullname: "MyUser"
My bidata class
@IgnoreExtraProperties
public class Biodata {
public String Fullname;
public String Email;
public Biodata() {
}
public Biodata(String Fullname, String Email) {
this.Fullname = Fullname;
this.Email = Email;
}
}
So, how can i prevent my app to insert same data twice ?