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.
Related
I try to make an app on Android for services reviews, every review is save like an element in the document "user" like this-
Everytime the user save a report I have see if inside the reports the field "plate" is existing comparing with the new one, I try query using the examples in the page arrays in Firebase
In the code i tried get with "whereEqualTo" method search by "reports.plate" or with the method "whereArrayContains" with the same field (the filter uid exits but in the first image doesn't show) any idea how i can search the document when some of the custom elements fields is equal
maybe sorry in advance for the english i'm practicing
Thanks in advance
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 using firebase database to store data. I know how to use firebase database.
In my project I've an activity which displays a list of notices from faculties to students and by clicking on list item it will open another activity which is a chat room. In this activity student can ask question related to given notice.
Now, In first list activity I've also added on text view which displays the total number of chat messages for that particular Notice. It works well when i load data from database initially. But i want to change number of chat messages dynamically.
So, i need to listnen at chat_cnt node to update value of message_cnt text view
and problem is it is a big list so i can not use child_added for each and every notice item and if i use value_event listener than it will load all data unnecessarily at start.
The code is a little bit big so i cannot post it here. But I've described the problem.
Any answer would be appreciated, thanks. Sorry for my english :)
in android stuido I would like to code an activity, where the user can input numbers. For, example he types the number to the textfield, click 'OK' button, then the textfield gets clear, he types the second number, than the third, and after they give the third number the program goes to another activity and sayst thanks for the free number. I would like to save the three numbers for further use and have them in an ascending order. How should I do it?
I agree with Andrii, this is a very vague and general question. To get you pointed in the right direction though, you would want a layout with an number based-editText widget (for the user input). I would then add the button, and then implement OnClickListener for the button so that everytime the button is pressed, it calls a method you will define that will store the value in an array or list (which can be sorted), along with some kind of tracker to keep track of how many numbers have been entered - then clearing the editText field so that another number can be input; on the third number, the method calls the activity via intent or some other way saying "thanks for the free number".
This is all general and it is going to take quite a bit of work and API Guide/DeveloperDocs searching on the Android web site.
I have an android app which displays quotes and have navigation to go to next quote and so on. would like to add "Save Quote As favourite" based on users selection of particular quote.
Once user saves Fav quotes and wants to see those quotes only, app should show those quotes.
Currently app reads the quotes from XML file. Let me know if any more information is required to understand the problem.
I would provide every quote with an ID (int). Whenever the user selects a quote to be a favourite, that ID is saved to a Set of integers. Later on if user decides to show favourites, you fetch all quotes with your IDs from the Set and show them in a appropriate view, for example a ListView
If you have a Quote class or something like that, you might as well put them in a collection whenever user decide his favourites, and show them in a ListView with a custom adapter.