我想通过onstart()方法将数据保存到firebase,但无法正常工作。
@Override
protected void onStart() {
super.onStart();
mDatabase = FirebaseDatabase.getInstance().getReference();
Transaction payment=new Transaction("merchant","user","1000","live");
mDatabase.child("transctions").child("2").setValue(payment);
}
答案 0 :(得分:0)
我们只需要在onstart()中初始化数据库引用。
@Override
protected void onStart() {
super.onStart();
DatabaseReference mDatabase;
mDatabase = FirebaseDatabase.getInstance().getReference();
Transaction payment=new Transaction("merchant","user","1000","live");
mDatabase.child("transctions").child("2").setValue(payment);
}