This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?xml version="1.0" encoding="utf-8"?> | |
| <shape xmlns:android="http://schemas.android.com/apk/res/android" | |
| android:shape="rectangle"> | |
| <solid | |
| android:color="@android:color/white"> | |
| </solid> | |
| <corners | |
| android:bottomLeftRadius="@dimen/_25sdp" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?xml version="1.0" encoding="utf-8"?> | |
| <androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android" | |
| xmlns:app="http://schemas.android.com/apk/res-auto" | |
| xmlns:tools="http://schemas.android.com/tools" | |
| android:layout_width="match_parent" | |
| android:layout_height="match_parent" | |
| android:background="@android:color/white" | |
| tools:context=".SignUp"> | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package com.arslan6015.demodatabase; | |
| import androidx.appcompat.app.AppCompatActivity; | |
| import android.os.Bundle; | |
| import android.util.Log; | |
| import com.google.firebase.database.DataSnapshot; | |
| import com.google.firebase.database.DatabaseError; | |
| import com.google.firebase.database.DatabaseReference; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // Read from the database | |
| myRef.addValueEventListener(new ValueEventListener() { | |
| @Override | |
| public void onDataChange(DataSnapshot dataSnapshot) { | |
| // This method is called once with the initial value and again | |
| // whenever data at this location is updated. | |
| String value = dataSnapshot.getValue(String.class); | |
| Log.d(TAG, "Value is: " + value); | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| FirebaseDatabase database = FirebaseDatabase.getInstance(); | |
| //you can also use .child() to get the same results | |
| DatabaseReference myRef = database.getReference("message").child("java").child("user"); | |
| myRef.setValue("Hello, Worldd!"); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // Write a message to the database | |
| FirebaseDatabase database = FirebaseDatabase.getInstance(); | |
| DatabaseReference myRef = database.getReference("message/java/user"); //set path to get the multiple dropdown nodes | |
| myRef.setValue("Hello, World!"); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // Write a message to the database | |
| FirebaseDatabase database = FirebaseDatabase.getInstance(); // Get the database instance and store into object | |
| DatabaseReference myRef = database.getReference("message"); // getReference() get the refrence if the refrence is already creted... if refrence is not created then it will create a new refrence here | |
| myRef.setValue("Hello, World!"); // assign value to the particular refrence. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // Validates timestamp is not a future value | |
| { | |
| “rules”: { | |
| “posts”: { | |
| “$uid”: { | |
| “timestamp”: { | |
| “.validate”: “newData.val() <= now” | |
| } | |
| } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // Checks presence of child attributes | |
| { | |
| “rules”: { | |
| “posts”: { | |
| “$uid”: { | |
| “.validate”: “newData.hasChildren([‘username’, ‘timestamp’])” | |
| } | |
| } | |
| } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // Validates string datatype and length range | |
| { | |
| “rules”: { | |
| “posts”: { | |
| “$uid”: { | |
| “.validate”: “newData.isString() | |
| && newData.val().length > 0 | |
| && newData.val().length <= 140” | |
| } | |
| } |