File tree Expand file tree Collapse file tree 3 files changed +25
-2
lines changed
database/app/src/main/java/com/google/firebase/referencecode/database
firestore/app/src/main/java/com/google/example/firestore/kotlin Expand file tree Collapse file tree 3 files changed +25
-2
lines changed Original file line number Diff line number Diff line change @@ -13,10 +13,10 @@ public void emulatorSettings() {
1313 // [END rtdb_emulator_connect]
1414 }
1515
16- public void flushRealtimeDatabase (FirebaseDatabase ) {
16+ public void flushRealtimeDatabase (FirebaseDatabase database ) {
1717 // [START rtdb_emulator_flush]
1818 // With a DatabaseReference, write null to clear the database.
19- FirebaseDatabase . getInstance () .getReference ().setValue (null );
19+ database .getReference ().setValue (null );
2020 // [END rtdb_emulator_flush]
2121
2222 }
Original file line number Diff line number Diff line change 1+ package com.google.firebase.referencecode.database.kotlin
2+
3+ import com.google.firebase.database.FirebaseDatabase
4+
5+ class EmulatorSuite {
6+
7+ fun emulatorSettings () {
8+ // [START rtdb_emulator_connect]
9+ // 10.0.2.2 is the special IP address to connect to the 'localhost' of
10+ // the host computer from an Android emulator.
11+ // In almost all cases the ns (namespace) is your project ID.
12+ val database = FirebaseDatabase .getInstance(" http://10.0.2.2:9000?ns=YOUR_DATABASE_NAMESPACE" )
13+ // [END rtdb_emulator_connect]
14+ }
15+
16+ fun flushRealtimeDatabase (database : FirebaseDatabase ) {
17+ // [START rtdb_emulator_flush]
18+ // With a DatabaseReference, write null to clear the database.
19+ database.reference.setValue(null )
20+ // [END rtdb_emulator_flush]
21+ }
22+ }
Original file line number Diff line number Diff line change @@ -12,6 +12,7 @@ class EmulatorSuite {
1212 val settings = FirebaseFirestoreSettings .Builder ()
1313 .setHost(" 10.0.2.2:8080" )
1414 .setSslEnabled(false )
15+ .setPersistenceEnabled(false )
1516 .build()
1617
1718 val firestore = FirebaseFirestore .getInstance()
You can’t perform that action at this time.
0 commit comments