I've connected my app to Firebase Realtime database and have set up a data class but haven't found a way to save an int to the database. I would like to store the number of times a user presses a certain button. I have seen a few yt tutorials but haven't gotten past this step since I couldn't find one that's specifically for Int and not String.
Data Class:
data class Total(val amount: Int? = null)
Activity:
class SecondActivity : AppCompatActivity() {
private lateinit var Total: Total
private lateinit var amount : Total
var database : DatabaseReference = FirebaseDatabase.getInstance().getReference("Total")
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_second)
var incrementNumber = 0
button_increment.setOnClickListener {
database.child("value").setValue(incrementNumber);
"Button has been pressed $incrementNumber times!".also {increment_textview.text = it }
}
}
}