firebase-realtime-database

Having issue retrieving correct information from Firebase with multiple lookups

試著忘記壹切 提交于 2020-01-05 05:38:25
问题 Below is the code I implemented which works but its assigning the last Firebase child 'PoolName' and 'PoolId' to all three (3) results when they should be different!? playerInPoolReference = mFirebaseDatabase.getReference("PlayerInPool").child(userID); playerInPoolReference.addValueEventListener(new ValueEventListener() { @Override public void onDataChange(DataSnapshot dataSnapshot) { if(dataSnapshot.exists()) { for (DataSnapshot poolSnapshot : dataSnapshot.getChildren()) { String poolID =

Not able to retrieve data field from Firebase database

泪湿孤枕 提交于 2020-01-05 05:37:27
问题 I have been trying to retrieve data fields from my firebase database for the past 5 days without any success. This is what my database looks like: Code for fetching data: private void alterTextView(final String id) { if(id!=null) { mDatabase.child("Users").child(id).addValueEventListener(new ValueEventListener() { @Override public void onDataChange(DataSnapshot dataSnapshot) { UserInformation userInformation = dataSnapshot.getValue(UserInformation.class); String name = (String)

Firebase QueryOrderedByChild along with EqualToValue and StartingAtValue Combination

允我心安 提交于 2020-01-05 05:32:07
问题 I am trying to query Firebase by a Child that is equal to a certain value BUT start the snapshot at a specific post key. Data Structure: projectName -posts -postKey1 -storeId: 1 -postKey2 -storeId: 2 -postKey3 -storeId:3 -postKey4 -storeId:2 -postKey5 -storeId:3 -postKey6 -storeId:2 Example: I am trying to queryOrderedByChild("storeId") with queryEqualToValue("2") BUT I would like the snapshot to start at "postKey4" when it is returned in its order. My Current Query: ref.queryOrderedByChild(

Is there any chance DataSnapshot value is null?

纵然是瞬间 提交于 2020-01-05 05:29:06
问题 I am answering this question then this new question come to my mind. In that question, I describe my example code like this: boolean firstCallDone = false; boolean secondCallDone = false; DataSnapshot firstDataSnapshot = null; DataSnapshot secondDataSnapshot = null; onCreate() { firstRef.addListenerForSingleValueEvent(new ValueEventListener() { @Override public void onDataChange(DataSnapshot dataSnapshot) { firstCallDone = true; firstDataSnapshot = dataSnapshot; if (firsCallDone &&

How to detect if ValueEventListener has fetched data or not in Firebase

萝らか妹 提交于 2020-01-05 05:10:37
问题 I'm using following code to fetch the data from Firebase DB but as it makes network request in background thread so I want to wait till it completes the request and get a value. For example, boolean isAvailable=false; usernameReference.addListenerForSingleValueEvent(new ValueEventListener() { @Override public void onDataChange(DataSnapshot dataSnapshot) { isAvailable = true; } @Override public void onCancelled(DatabaseError databaseError) { progressBar.setVisibility(View.GONE); } }); if

Android Firebase Database Adding items with keys to recycler view

狂风中的少年 提交于 2020-01-05 05:09:13
问题 I was trying to add & show messages dynamically in recycler view but I could not figure out how to send proper data type to it's adapter. In "getNewMessage(dataSnapshot) " function, I have to add all messages to list and send it to recycler view via adapter. I tried both MessageModel model = dataSnapshot.getValue(MessageModel.class) and creating a SampleModel that contains List<MessageModel> list , and SampleModel model = dataSnapshot.getValue(SampleModel.class); They didn't work. Here sample

How to send hierarchical data from firebase to google sheet

て烟熏妆下的殇ゞ 提交于 2020-01-05 04:58:11
问题 below is the hierarchy of my data present in firebase database. I want to send this data to google sheet but I am unable to do so. Error stated by google sheet is "TypeError: Cannot read property "rytf1JLXetTIINjHNku0yAvs7su2" from undefined. Details" Below is the code that I am trying to retrieve data. Kindly let me know the mistake. Thank you! function writeSheets() { var ss = SpreadsheetApp.openById("google-sheet-id"); var firebaseUrl = "database-url"; var base = FirebaseApp

Not able to get the array values from firebase database

£可爱£侵袭症+ 提交于 2020-01-05 04:57:30
问题 I'm trying to check whether the signed in user is an authorized user from the JSON array in Firebase Database. How do I get the value of email field from Firebase. ? This is the model User class: public class User { ArrayList<User> email; public User() {} public ArrayList<User> getEmail() { return email; } public void setEmail(ArrayList<User> email) { this.email = email; } } For getting the email from userslist , I used this logic. usersListDatabaseReference.addValueEventListener(new

Updating Firebase Database with nodes created with push

痞子三分冷 提交于 2020-01-05 04:40:32
问题 I am trying to update a value in my Firebase database. This is the structure of the database: I need to update the value of status to "accepted" if the r_id and s_id have a specific value. The problem here is that the key for each friend_data child is generated using "push" like this db.child("friend_data").push().setValue(friend); I have tried this question here and this one here but both don't meet my requirements. How do I go about solving this one? Edit: I understand now that I am

Firebase Database Search Query

有些话、适合烂在心里 提交于 2020-01-05 04:33:14
问题 I am trying to search my database using a string, such as "A". I was just watching this Firebase tutorial Common SQL Queries converted for the Firebase Database - The Firebase Database For SQL Developers #4 and it explains that, in order to search the database for a string (in a certain location), you must use: firebase.database().ref.child("child_name_here") .queryOrdered(byChild: "child_name_here") .queryStarting(atValue: "value_here_uppercase") .queryEnding(atValue: "value_here_uppercase\