Created
April 24, 2023 21:48
-
-
Save saqib-github-commits/fe11c0e94c03192a732599e3547049eb to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Create Database Object | |
val database = FirebaseDatabase.getInstance("<database path>") | |
val databaseRef = database.reference | |
// Read from the database | |
databaseRef.addValueEventListener(object : ValueEventListener { | |
override fun onDataChange(dataSnapshot: DataSnapshot) { | |
// This method is called once with the initial value and again | |
// whenever data at this location is updated. | |
val value = dataSnapshot.value | |
Log.d(TAG, "Value is: $value") | |
} | |
override fun onCancelled(error: DatabaseError) { | |
// Failed to read value | |
Log.w(TAG, "Failed to read value.", error.toException()) | |
} | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment