How to Connect an Android Application to Firebase Realtime Database / Firestore and write a simple database (Kotlin / Java)

I’ll be show you simple way, how your project connecting with firebase 😊

add project
my project firebase

The first way is using Android Studio 🙈

step connect account
choose firebase
connect with Firestore
connect with Realtime Database
click to connect
select you project
complete to connected firestore
complete to connected realtime database


see database

HELLO WORLD!! Lets Write.

1. Simple Write “Hello World” on Firestore

val db = FirebaseFirestore.getInstance()

val user: MutableMap<String, Any> = HashMap()
user["word1"] = "Hello"
user["word2"] = "World"
user["word3"] = "Im rivaldy!! :)"

.addOnSuccessListener { documentReference -> Log.d("Message", "DocumentSnapshot added with ID: " + }
.addOnFailureListener { e -> Log.w("Message", "Error adding document", e) }
FirebaseFirestore db = FirebaseFirestore.getInstance();
Map<String, Object> user = new HashMap<>();
user.put("word1", "Hello");
user.put("word2", "World");
user.put("word3", "Im rivaldy!! :)");
.addOnSuccessListener(new OnSuccessListener<DocumentReference>() {
public void onSuccess(DocumentReference documentReference) {
Log.d(TAG, "DocumentSnapshot added with ID: " + documentReference.getId());
.addOnFailureListener(new OnFailureListener() {
public void onFailure(@NonNull Exception e) {
Log.w(TAG, "Error adding document", e);
rules firestore database
hello world firestore

2. Simple Write “Hello World” on Realtime database

val database = FirebaseDatabase.getInstance()
val myRef = database.getReference("message")
myRef.setValue("Hello World!! Im Rival :)")
FirebaseDatabase database = FirebaseDatabase.getInstance();
DatabaseReference myRef = database.getReference(“message”);
myRef.setValue(“Hello World!! Im Rival :)”);
hello world!!


Thankyou….. 😇😇

i write just for fun | find me on my github | @rivaldy_o ☕🎧