Reputation: 106
I am new in android i want to know what is use of firebase database. And how can I use this database.?
How I store data in this database and how to access data from that database.?
Upvotes: 1
Views: 2949
Reputation: 34360
first you should dig into some research and then ask question.
But AFAIK firebase lacks documentation. So I will try to explain steps to it.
read firebase documentation, and use updated Method from here
First of all go to firebase Console and create a project(give it name and location)
If you want to read write data without Authentication steps then change rules in firebase console like
{
"rules":
{
".read": true,
".write": true
}
}
If you want to add firebase manually. Go to project settings and select android. give packageName
, where name and SHA-1 is optional. download google-service.json
and in android studio change it's view to Project and paste it under app folder.
Add below dependency to project build.gradle
dependencies {
classpath 'com.android.tools.build:gradle:2.1.3'
classpath 'com.google.gms:google-services:3.1.0'
}
and at app Level build.gradle.
dependencies {
compile 'com.google.firebase:firebase-database:9.4.0'
}
//add it at the bottom of app level build.gradle
apply plugin: 'com.google.gms.google-services'
Add internet permission in Manifest
and to set data to firebase Use
FirebaseDatabase database = FirebaseDatabase.getInstance();
DatabaseReference myRef = database.getReference("rootNode "); // yourwebisteurl/rootNode if it exist otherwise don't pass any string to it.
myRef.setValue("Hello, World!");
or
DatabaseReference database =
FirebaseDatabase.getInstance().getReference();
DatabaseReference ref = database.child("rootNode");//if rootNode exist
database.setValue("TestRefValue");
Note
i. Upgrade Google Play Services
and Google Repository
Some Helpful links for reading Database from Firebase.
Upvotes: 2
Reputation: 2297
I think firecast are the most helpful resources available there as a quick start to firebase and they are pretty nicely done. Check this out it helped me a lot when i stated with firebase https://www.youtube.com/watch?v=B1rlT5KQ0yE
Upvotes: 1
Reputation: 2213
The Firebase documentation is a good place to start, but if you need tutorials to get started with Firebase I recommend the Firebase essentials course from Udacity and Google :
https://www.udacity.com/course/firebase-essentials-for-android--ud009
It's free and there's two major course content updates coming soon.
Upvotes: 1