210 likes | 230 Views
Firebase is a middle ware that allows you to perform a variety of functions across different platforms. This includes beta products, Firebase console, analytics, push notifications, and real-time database.
E N D
What is firebase? It's basically middle ware that allows you do a number of things cross platform
What is firebase? Beta products
Data • The data is stored as a json object. • The L7W.. Is a unique key, that I didn't have to create. • You will need a POJO class that matches your data names
Database notes • Firebase Realtime Database allows nesting data up to 32 levels deep, but where possible avoid nesting deep. • Also don't use json arrays.
Receive the data db.collection("users").document("Jim").get() .addOnCompleteListener(new OnCompleteListener<DocumentSnapshot>() { @Override public void onComplete(@NonNull Task<DocumentSnapshot> task) { if (task.isSuccessful()) { DocumentSnapshot snapshot = task.getResult(); Map<String, Object> data = snapshot.getData(); TestText= String.valueOf(data.get("text")); Arr= String.valueOf(data.get("Arrow")); } } });
To get multiple documents from a collection db.collection("users") .get() .addOnCompleteListener(new OnCompleteListener<QuerySnapshot>() { @Override public void onComplete(@NonNull Task<QuerySnapshot> task) { if (task.isSuccessful()) { //iterate over the documents. for (QueryDocumentSnapshot document : task.getResult()) { //using document.getData() to get each one. } } else { Log.w(TAG, "Error getting documents.", task.getException()); } } });
Retrieve via a listener DocumentReferencedocRef = db.collection("sign").document("Jim"); docRef.addSnapshotListener(new EventListener<DocumentSnapshot>() { @Override public void onEvent(@NullableDocumentSnapshot snapshot, @NullableFirebaseFirestoreException e) { if (e != null) { Log.w(TAG, "Listen failed.", e); return; } //retrieve the data if it exists. if (snapshot != null && snapshot.exists()) { Map<String, Object> data = snapshot.getData(); TestText = String.valueOf(data.get("text")); Arr= String.valueOf(data.get("Arrow")); } } });
References https://console.firebase.google.com/ https://firebase.google.com/docs/ Many of the sub doc's where listed on slides.
Thank You