I wrote the following code: It fetches the user’s full name and image and set them in the menu. I want to set a listener to those two fields so every time there is a change in the database, it will update connectedFullName and connectedImageURL and call the setMenuAvatarImage, setMenuHeaderMessage methods. How can I do it? Answer What you’re describing
Tag: google-cloud-firestore
Data Retrieval from Firestore is erratic
I’m working on an Android app that does the following: Upon app start-up, it checks if a user is logged in, using AuthStateListener. If there is a user logged in, it retrieves data from Firestore. The user data is stored in a document that I named with the following nomenclature: “User ” + user’s_email_ID. For example, if a user has
Firestore Paging Adapter- How to know if query returns 0 results
I’m using firestore paging adapter to populate my RecyclerView with data from Firestore, if collection in Firestore is empty I would like to show a TextView to inform user about that, if it is not then I would like to populate EecyclerView with data but I don’t see a way to do this with Firestore paging adapter because I can’t
How to populate a spinner with the result of a Firestore query?
I am creating a spinner which will show the subject name. The subject names are stored in my Firestore database as follows: I could fetch the result to an RecyclerView but unable to help myself to do so for spinner. Answer To solve this, please use the following lines of code: The result will be a spinner that will contain
How to fix Android Cloud Firestore document snapshot
I am checking if the user has made an appointment in the database if not add the user(add a new document which has the user details). The problem with my app is that it runs both AddUser() and AlertUser() functions: Answer What does this code do is checking whether a document with the userIdentity id actually exists. If it doesn’t
FireStore date query not working as expected
I have doc which has a date object. Code to init Firestore: Code to query: I am always getting all the records and looks like the where clause is not getting applied. On Firebase console I see that the endDate is stored as timestamp. Doc from Firebase console: Answer Cloud Firestore queries are immutable, which means that you cannot change
Checking if a document exists in a Firestore collection
I have a Firestore collection tree in which I plan to store only one document. I want to check if that collection contains that document and if so, retrieve the id of the document! Any ideas/thoughts? Thanks 🙂 Answer If you want to check a particular document for existence based on its document id, please use the following lines of
What is the correct way to structure this kind of data in Firestore?
I have seen videos and read the documentation of Cloud firestore, from Google Firebase service, but I can’t figure this out coming from realtime database. I have this web app in mind in which I want to store my providers from different category of products. I want perform a search query through all my products to find what providers I
Firestore Security Rules: use array_contains to determine authorization
Can I use the equivalent of array_contains in Firebase Security Rules? I have an Event class (corresponding to Event documents in the events collection). Each document has a subscribers list/array that contains the UIDs of all the users who should be able to query for this event: More explicitly, a user should be able to run the query: How do
How to update array elements in Firestore with Android?
I read this post and this post of the same guy saying that you cannot update array elements. I also read a recent article, where is says that this can be done somehow with arrayUnion or something like that but I cannot get any informations on stackoverflow either in the docs. Is there any way I can solve this? Thanks!