Firebase. Database. FirebaseDatabase
The entry point for accessing aFirebaseDatabase.
Summary
The entry point for accessing aFirebaseDatabase. You can get an instance by callingDefaultInstance . To access a location in the database and read or write data, useGetReference()
Properties | |
|---|---|
App | Returns theFirebase.FirebaseApp instance to which thisFirebaseDatabase belongs. |
DefaultInstance | staticFirebaseDatabaseGets the instance ofFirebaseDatabase for the default Firebase.App. |
LogLevel | |
RootReference | Gets aDatabaseReference for the root location of thisFirebaseDatabase. |
Public static functions | |
|---|---|
GetInstance(FirebaseApp app) | Gets an instance ofFirebaseDatabase for a specificFirebase.FirebaseApp. |
GetInstance(String url) | Gets an instance ofFirebaseDatabase for the specified URL. |
GetInstance(FirebaseApp app, String url) | Gets aFirebaseDatabase instance for the specified URL, using the specified FirebsaeApp. |
Public functions | |
|---|---|
GetReference(string path) | Gets aDatabaseReference for the provided path. |
GetReferenceFromUrl(Uri url) | Gets aDatabaseReference for the provided URL. |
GetReferenceFromUrl(string url) | Gets aDatabaseReference for the provided URL. |
GoOffline() | void |
GoOnline() | void |
PurgeOutstandingWrites() | void |
SetPersistenceEnabled(bool enabled) | voidSets whether pending write data will persist between application exits. |
Properties
App
FirebaseAppApp
Returns theFirebase.FirebaseApp instance to which thisFirebaseDatabase belongs.
| Details | |
|---|---|
| Returns | TheFirebase.FirebaseApp instance to which thisFirebaseDatabase belongs. |
DefaultInstance
staticFirebaseDatabaseDefaultInstance
Gets the instance ofFirebaseDatabase for the default Firebase.App.
AFirebaseDatabase instance.
LogLevel
LogLevelLogLevel
By default, this is set toInfo This includes any internal errors (Error ) and any security debug messages (Info ) that the client receives.
Set toDebug to turn on the diagnostic logging.
On Android this can only be set before any operations have been performed with the object.
The desired minimum log level
RootReference
DatabaseReferenceRootReference
Gets aDatabaseReference for the root location of thisFirebaseDatabase.
ADatabaseReference instance.
Public static functions
GetInstance
FirebaseDatabaseGetInstance(FirebaseAppapp)
Gets an instance ofFirebaseDatabase for a specificFirebase.FirebaseApp.
| Details | |||
|---|---|---|---|
| Parameters |
| ||
| Returns | AFirebaseDatabase instance. |
GetInstance
FirebaseDatabaseGetInstance(Stringurl)
Gets an instance ofFirebaseDatabase for the specified URL.
| Details | |||
|---|---|---|---|
| Parameters |
| ||
| Returns | AFirebaseDatabase instance. |
GetInstance
FirebaseDatabaseGetInstance(FirebaseAppapp,Stringurl)
Gets aFirebaseDatabase instance for the specified URL, using the specified FirebsaeApp.
| Details | |||||
|---|---|---|---|---|---|
| Parameters |
| ||||
| Returns | AFirebaseDatabase instance. |
Public functions
GetReference
DatabaseReferenceGetReference(stringpath)
Gets aDatabaseReference for the provided path.
| Details | |||
|---|---|---|---|
| Parameters |
| ||
| Returns | ADatabaseReference pointing to the specified path. |
GetReferenceFromUrl
DatabaseReferenceGetReferenceFromUrl(Uriurl)
Gets aDatabaseReference for the provided URL.
Gets aDatabaseReference for the provided URL. The URL must be a URL to a path within thisFirebaseDatabase. To create aDatabaseReference to a different database, create aFirebase.FirebaseApp with a
object configured with the appropriate database URL.
| Details | |||
|---|---|---|---|
| Parameters |
| ||
| Returns | ADatabaseReference for the provided URL. |
GetReferenceFromUrl
DatabaseReferenceGetReferenceFromUrl(stringurl)
Gets aDatabaseReference for the provided URL.
Gets aDatabaseReference for the provided URL. The URL must be a URL to a path within thisFirebaseDatabase. To create aDatabaseReference to a different database, create aFirebase.FirebaseApp with a
object configured with the appropriate database URL.
| Details | |||
|---|---|---|---|
| Parameters |
| ||
| Returns | ADatabaseReference for the provided URL. |
GoOffline
voidGoOffline()
Shuts down our connection to theFirebaseDatabase backend untilGoOnline() is called.
GoOnline
voidGoOnline()
Resumes our connection to theFirebaseDatabase backend after a previousGoOffline() Call.
PurgeOutstandingWrites
voidPurgeOutstandingWrites()
TheFirebaseDatabase client automatically queues writes and sends them to the server at the earliest opportunity, depending on network connectivity.
TheFirebaseDatabase client automatically queues writes and sends them to the server at the earliest opportunity, depending on network connectivity. In some cases (e.g. offline usage) there may be a large number of writes waiting to be sent. Calling this method will purge all outstanding writes so they are abandoned. All writes will be purged, including transactions andDatabaseReference.OnDisconnect() writes. The writes will be rolled back locally, perhaps triggering events for affected event listeners, and the client will not (re-)send them to theFirebase backend.
SetPersistenceEnabled
voidSetPersistenceEnabled(boolenabled)
Sets whether pending write data will persist between application exits.
TheFirebaseDatabase client will cache synchronized data and keep track of all writes you've initiated while your application is running. It seamlessly handles intermittent network connections and re-sends write operations when the network connection is restored. However by default your write operations and cached data are only stored in-memory and will be lost when your app restarts. By setting this value to true, the data will be persisted to on-device (disk) storage and will thus be available again when the app is restarted (even when there is no network connectivity at that time).
Note:SetPersistenceEnabled should be called before creating any instances ofDatabaseReference, and only needs to be called once per application.
| Details | |||
|---|---|---|---|
| Parameters |
|
Except as otherwise noted, the content of this page is licensed under theCreative Commons Attribution 4.0 License, and code samples are licensed under theApache 2.0 License. For details, see theGoogle Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2021-06-17 UTC.