Store Int Using Firebase Realtime Database
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
Solution 1:
To atomically increment a value in the database, you can do:
Database.database().reference().setValue(["counter": ServerValue.increment(1)]);
If the value already exists, this increments it by 1. If the value doesn't exist yet, this sets it to 1.
Post a Comment for "Store Int Using Firebase Realtime Database"