I'm in "Master", I would like to read all the children, and obtain, based on a single attribute (child) of "Master" that satisfies a condition, the respective UID. I would then save the UID to a string. But I don't know the method to do it. Could someone point me to a solution.
enter image description here
Related
I want to delete the yellow user in the screenshot if he decides to delete his account. The blue X is a different user. How do I do that?
In the second picture is my attempt. I don't know how to get the userid of the blue X.
Your current data structure makes it easy to find the yellow Followers for a given blue Follow node. It does not however make it easy to find the blue node for a given yellow one. In fact, to allow that you will have to read all blue nodes, and check each individual Followers child node in turn.
To more easily allow your use-case, you'll want to also store the inverse data structure that allows you to find the blue Follow nodes for a given yellow Follower value. I typically refer to this as the Followee map, although I admit I'm not sure if that's even a word:
Followees: {
"ky....Yhi1": {
"L5w...6rF3": true
}
}
Now with this structure, you can find the "L5w...6rF3" key based on knowing the "ky....Yhi1" value and delete the user from the Followers node there.
We covered this scenario a few times before, so I recommend also checking out:
Firebase query if child of child contains a value
Firebase Query Double Nested
Many to Many relationship in Firebase
I can successfully retrieve documents from firestore, the trouble is, i do not know how to put them back where they came from!!
My app is a court booking system, it uses 7 fragments that represent the days of the week. Each fragment contains buttons that represent booking slots throughout the day. When a button is pressed, the court booking activity fires showing textviews and spinners.
The information I save to firestore includes a unique number representing a datestamp and a booking id that represents the id of the button that was pressed.... from here, I am lost, i need to write the retrieved database info back to their relevant places but i dont have anything unique in the way of widgets. The buttons are unique but all they do is fire a non unique court booking activity... any help appreciated... sorry for length, quite possibly more to add when answering questions.
To write to a document in Firestore you need to know the complete path to that document. You'll need to track the necessary IDs in your code, in a way that you can synchronize it with your UI elements.
A simple first pass could be to add a non-editable view (e.g. a label) to your UI for each document, and set the document ID (or entire path) in there. Then when the user clicks a button, you find the corresponding view with the ID, and from that can recreate the DocumentReference that you need to update.
I am working on an Android application where there are two types of user. I differentiate them into the system by using the field UserType. I have a requirement where I have to copy data from one child node into another. I am using Firebase for my backend. I have gone through other answers but this requirement is unique in a way that, I want to copy data only on a particular node. Attaching the Firebase database structure
In this structure, if you can see I have expanded 2 child nodes of "users". One of the child has userType as Standard User and other child has userType as Guardian User.
1) I want to copy the "fullNameGuardian" child alone from the user with key starting with "L4bTr6q" to the user with key starting with "dC9Mq"
2) I want to copy the "standardEmail" child alone from the user with key starting with "dC9Mq" to user with key starting with "L4bTr6q".
And everytime I add a new user, the user can be with one of the userType "Standard User" or "Guardian User". So is there a possibility like I do it for every new user?
I am having difficulties figuring out how to do this. Any help is appreciated. Thanks a lot in advance.
I think you could save the other structure when you save the first one. For instance,
Save - node1/child
Update - node2/child
//and so on
Another way is using Firebase functions(Real database triggers) in order to automatically do something after something else had happened. Check it out.
I'm new in Firebase realtime database, and I have to save some special characters in the database like the following:
https://myProject.firebaseio.com/myProject/en/$fanny/weight
Note: the child could contain any special character not just only $
How could I handle such like this issue please?
As I see there are some guys are replacing the characters, but in my case I should not change the values, because I have to display it to the users as is because it has a meaningful to the user.
The only solution is to replace the invalid characters in the keys.
If you need to display the original value to the user, also store it as a value.
I am trying to develop a user input form where i take his details and store them
in the form i have fields for his name, email, address, phone number etc.
a person may have multiple emails or multiple phone numbers.
he can add a field by clicking a button.
and then i want to store the data entered by the user in a shared preference.
i have a question:
how do i retrieve data from dynamically added extra fields by the user?
I have maintained a count for dynamically added fields for each field criteria (like email, phone etc)
but i am stuck at the point where i am supposed to retrieve the data when i need to store them in Shared Preferences.
Please help! thankyou in advance.
Is it possible using something like ParentViewGroup.getChildCount() or something else?
Sure, you can use getChildCount() and getChildAt() methods to retrieve child from a ViewGroup.
However, I think the better way is to save the references to the Views you added when you add them into the View hierarchy, and get data from these references.