Is there a way to send Number from NumberPicker
to Firebase
? I have connected a NumberPicker
library from GITHUB
. But I want when select number to send to Firebase
, is there a way ?
I tried with this code :
String number = numberPicker.getText().toString().trim();
Code for Firebase:
private boolean updateProdus(String id, String number){
DatabaseReference databaseReference = FirebaseDatabase.getInstance().getReference("produse").child(id);
Produse produse = new Produse(id, number);
databaseReference.setValue(produse);
Toast.makeText(this, "Edited", Toast.LENGTH_LONG).show();
return true;
}
But it's not working.
private boolean updateProdus(String id, String number){
DatabaseReference databaseReference = FirebaseDatabase.getInstance().getReference("produse").push();
databaseReference.child("number").setValue(number);
Toast.makeText(this, "Edited", Toast.LENGTH_LONG).show();
return true;
}
Use push()
to create a random id, then inside of it there will be a child that has the value number.
check this: https://developer.android.com/reference/android/widget/NumberPicker.html
you can get the number doing this:
String number=""+numberpicker.getValue();