How to Retrieve Data From Firestore with Kotlin ?

Sudish Kumar
Dec 16, 2020

Google Firestore Provides No SQL database where we can keep data and it is a flexible, scalable database for mobile, web, and server development from Firebase and Google Cloud Platform.

For more about Google Firestore you can visit on bellow the link https://firebase.google.com/docs/firestore?authuser=0

Your project should be added in your Firebase Project

Add dependencies directly Open your project in android studio Tools>Firebase > Firestore> click on Add Dependencies

MainActivity.kt

var firestore: FirebaseFirestore
firestore = FirebaseFirestore.getInstance()
firestore.collection("users")
.get()
.addOnSuccessListener {
Toast.makeText(this, "Your first name is ${it.documents.get(0).data?.get("first_name") } and last name is ${it.documents.get(0).data?.get("last_name") }", Toast.LENGTH_SHORT).show()
}
.addOnFailureListener{
it
.printStackTrace()
Toast.makeText(this, "Failed", Toast.LENGTH_SHORT).show()
}
}

That’s all , Thank you for reading my article

you can see my project on GitLab

https://gitlab.com/sudishkumar/retrieve-data-from-firebase-kotlin

Sign up to discover human stories that deepen your understanding of the world.

Free

Distraction-free reading. No ads.

Organize your knowledge with lists and highlights.

Tell your story. Find your audience.

Membership

Read member-only stories

Support writers you read most

Earn money for your writing

Listen to audio narrations

Read offline with the Medium app

Sudish Kumar
Sudish Kumar

Written by Sudish Kumar

Flutter | Android | Node | Dart | Kotlin | Java | JavaScript | TypeScript | PHP | Short Story Teller | Tech Lead

No responses yet

Write a response