Skip to content

Commit 7829845

Browse files
committed
2 parents 56dc929 + 90e205c commit 7829845

File tree

3 files changed

+25
-2
lines changed

3 files changed

+25
-2
lines changed

database/app/src/main/java/com/google/firebase/referencecode/database/EmulatorSuite.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff 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
}
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
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+
}

firestore/app/src/main/java/com/google/example/firestore/kotlin/EmulatorSuite.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff 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()

0 commit comments

Comments
 (0)