Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 6 years ago.
Improve this question
in my firebase database, I have lots of user to show on my Listview. I want my app load 10 item whenever click LoadButton.
You can use a simple firebase query, which returns the first 10 users.
Query userQuery = dbRef.child("users").limitToFirst(10);
You can also limit it to the last 10 by changing limitToFirst() to limitToLast()
Related
Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 7 days ago.
Improve this question
My code works strangely, it should update document in the room and the firebase. For some reason, instead of setting himself up, he set the last item in the RecyclerView
(https://i.stack.imgur.com/tJQbH.png)
I saw this code on the internet and just tried to copy it
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 10 months ago.
This post was edited and submitted for review 10 months ago and failed to reopen the post:
Opinion-based Update the question so it can be answered with facts and citations by editing this post.
Improve this question
I read on multiple stack overflow posts that we should'nt store questions and answers in Firestore for a quiz app in the same documents. So I created two collections, one represent the questions the other the answers. Here is my firestore architecture:
When the user clicks on a category the application get 10 questions of a category after the user can click on one answer for each questions. My problem is how to compare properly the answer the user clicks on with the good answer? I do not want the user to hack my game and know each good answer of all questions.
I see two options:
When the user clicks on an answer, my app send a query to firestore to retrieve the good answer of the question and once the data is loaded it compares with the answer that the users clicked on. I fear this solution because the user needs to wait the data loads when he clicks on the answer.
The second solution I see is to get all the 10 questions and good answers at the beginning of the game and store all goods answers in a list and retrieve the good answer with the question index. I don't know if the user can hack my app to see all good answers but he will not waits to get the result of his/her choice.
use like this
collection name->document name(u can also put document name
as question name) ->in document field you can store the value like picture show
rt means right answer in this question right answer is option b .
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 3 years ago.
Improve this question
I was wondering what is the best way to send a vote say for example the initial value of the vote is 0 and someone sends a +1 (vote+=1) after a certain time like 20min that vote will be undone (vote-=1). Is there some functionality in firebase to do this? Because I want the undoing to work even though the user isn't using the android application. I thought about keeping a device always connected to the database and watch the changes but this doesn't look very stable. Is it possible to use a server? If firebase isn't the best option what should I look up online?
cloud functions on read/right/updates to firestore is down your alley. The biggest problem i see is that you would use setTimeout for 20 minutes and you would get billed alot. Another forum with a similar problem recommends to run a cloud function every once in a while to purge old votes. I recommend on upvote push the date into an array and use length as the total number of votes, and every 10 minutes or whatever have a function run that looks if the dates are older than 20 minutes and deletes accordingly.
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 4 years ago.
Improve this question
I have a set of users which mark their status as online. I want to connect two random users in Firebase and my database is a Firestore Database. How can I achieve this?
You have not posted any code or idea of your own, hence I can't comment or tell you very specific things to your idea/code. But I'd try to be broad enough for this.
Using a special node like status and setting it to online and offline will be a good idea.
You can use orderByChild() to order all the users with status node set to online and get the uid of any of those users.
To make the process random you could make a call to users, take the ids given back to you, and pick one at random with a basic random number.
If after making a call to users you have 10 user ids in an array you would want to get a random number between 0-9 and then make a call to firebase with the userId.
I don't believe Firebase has any built in code for this. So this would be the best thing you can do to achieve this feature in your app.
You may also refer this question.
Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 7 years ago.
Improve this question
I would like create an application with a list of podcast with an UI like Google Music, but I do not know how to place items horizontally beside the other podcasts rather than below.
I use a listView and a cardView.
Well, GridView or a RecyclerView with a GridLayoutManager can do the trick.