Skip to main content

Firebase 2

Chat bot using Firebase (Read, write and database structure)
https://www.udacity.com/course/firebase-in-a-weekend-by-google-android--ud0352

Database Security Rules:
{
 "rules": {
   "chat" : {
     "messages" : {
       ".read": "auth != null",
       ".write": "auth != null"
     }
   },
   "special_chat" : {
     "messages": {
       ".read": 
       "root.child('users').child(auth.uid).child('paid').val() === true",
       ".write": 
       "root.child('users').child(auth.uid).child('paid').val() === true"
     }
   }
 }
}

Cascading Rules

When .read and .write rule permissions are evaluate to true, this cascades to all of the rule’s children. Only truth is cascading; falseness is not cascading.


Google Codelabs
https://codelabs.developers.google.com/codelabs/firebase-android/index.html?index=..%2F..%2Findex#2

How to get child of child value from firebase in android?

https://stackoverflow.com/questions/43293935/how-to-get-child-of-child-value-from-firebase-in-android?utm_medium=organic&utm_source=google_rich_qa&utm_campaign=google_rich_qa


Querying Data
https://stackoverflow.com/questions/39024702/firebase-querying-data


DatabaseReference reference = FirebaseDatabase.getInstance().getReference();

    Query query = reference.child("issue").orderByChild("id").equalTo(0);
    query.addListenerForSingleValueEvent(new ValueEventListener() {
        @Override
        public void onDataChange(DataSnapshot dataSnapshot) {
            if (dataSnapshot.exists()) {
                // dataSnapshot is the "issue" node with all children with id 0
                for (DataSnapshot issue : dataSnapshot.getChildren()) {
                    // do something with the individual "issues"
                }
            }
        }

        @Override
        public void onCancelled(DatabaseError databaseError) {

        }
    });
For more reference:

Basic information

Comments

Popular posts from this blog

RecyclerView

Benefit of RecyclerView: 1. Standby the next element for display 2. Saves Viewholder scrolled offscreen. Viewholder does not  need to be created or have its view inflated; instead, the app just updates the view's contents to match the new item it was bound to. 3. Adapter use  RecyclerView.adapter.notifyItemChanged to update changed items by rebinding Main Objects 1. RecyclerView Object: Overall container for UI that you add to layout.   The  RecyclerView  creates only as many view holders as are needed to display the on-screen portion of the dynamic content, plus a few extra.  As the user scrolls through the list, the  RecyclerView  takes the off-screen views and rebinds them to the data which is scrolling onto the screen. 2. Adapter: manage Viewholder Object (create and bind to data, onBindViewHolder()   ) 3. Viewholder Object: view in the list. Display a single item with a view 4. LayoutManager: add Views to RecyclerView https://developer.android.com/guide/topic

Error when renaming java class nameAndroid Studio

Do you see these terms,"java.lang.ClassNotFoundException, DexPathList", somewhere along the whole chunk of error message, wherever you rename a file? Simple solution would be to clean build! But do make sure the following are rename accordingly too, 1. class name on Directory 2. class: public class MainActivity extends .... 3. Manifest: <activity android:name=".MainActivity"> 4. XML: tools:context=".MainActivity" https://www.facebook.com/Android-Noob-Reboot-1248769758470969/ https://stackoverflow.com/questions/40493946/refactoring-package-name-breaks-app-with-classnotfoundexception-due-to-not-findi