Firebase: Save, Delete and Retrieve data from firebase database in Android Studio

In Firebase Realtime Database we can store and sync data with our NoSQL cloud database. Data is synced across all clients in realtime, and remains available when your app goes offline.

The Firebase Realtime Database is a cloud-hosted database. Data is stored as JSON and synchronized in realtime to every connected client. When you build cross-platform apps with our iOS, Android, and JavaScript SDKs, all of your clients share one Realtime Database instance and automatically receive updates with the newest data.

Android Setup

Here is the one example how to store on firebase and retrieve data on your android device.

First step Create firebase project  from https://console.firebase.google.com.

Add the dependency for Firebase Realtime Database to your app-level build.gradle file:



Update the rules for your database to allow reads and writes from all users, as this demo will not cover Firebase Authentication.


Steps:
1. Create firebase database reference
2. Get data from your form
3. Add and push data on database
4. Update on your view using creating anonymous inner class ChildEventListener.
5. Check you firebase database

Here is the full code:





Update on recyclerview, which show in below git hub link.

Output Snapshots:




Clone the github java
$git clone https://github.com/dharmakshetri/FirebaseAddOrDeleteonDatabase.git

Happy Coding !!!


No comments:

Post a Comment

Circle

Most recent Elastic Search tutorials for beginner, intermediate and advance level developer, Yubraj Pokharel, in CodingWorkspace