Reading and storing a set of data from Firebase Database? - android

I have set of data stored in Firebase Realtime Database (snapshot attached).
Click to View
I want to read this data when I press a button in my Android app and store it according to the person name, for example storing that Jack is 20 years old and Marry is an engineer, but I need to do this for more than just 3 users.
I'm able to call the data and read it but storing it in the way I described above is not working.
EDIT:
I added part of the code I'm working with, my main goal is when I click a button to call the data from Database, I'm able to do this but I can't figure out the best way to store this data in a way that I can use it. For example I want to display the name of the user and his role and age but I want to do this for as many users as available in database.
Code here

Related

Retrieve firebase RTDB data into Recycleview in random

How can such scenario be implemented in a social app Android java. I have built my app with Firebase RTDB and I am retrieving the data into a Recycleview using collection.shufflelist too so that I get random data displayed.
How to add another condition to collection.shufflelist(); that will make the latest post show at the top in that same random order but post that are created within the last 24 hours should be randomly placed at the top.
I have tried to use the logic of
reference.child().orderChildBy(timestap).startAt(system.currentTime....).StopAt(1356890000...) but I only saved date into my database in Simple date format, YY-MM-DD.
So I cannot add another node to save timestamps because app already has installs in several users phone changing database structure or adding new nodes/child may affect the app.
My question now on this situation how possible is it to set my random retrieved data to have the latest at the top?

From a high level, what is the best way to implement a fitness app which reads workouts from a database?

I'm designing a fitness app where a trainer would upload workouts to a database and a client could access those workouts via an app. This is easy enough to setup, however, I'm struggling to find a good way to upload workouts to a database in a way that someone who is non technical could easily do. I've been primarily playing around with FirebaseDB, but I'm open to suggestions. I'm trying to avoid having to create my own app for the trainer to input data and upload to the database as it will take extra time. Is this the best approach?
If you are thinking to expand your app in near future i suggest you to avoid FirebaseDB. Go with MS-SQL. Create User Table and add a Field may be called as 'Member_Types' (Admin|User). If the logged in user is Admin then Show him Different Page from where He can Upload Data by just inserting in Textboxes/Dropdowns/etc,etc and Clicking One Button Click. Whereas if the user logged in as a USER type show him the page which shows the data uploaded by Admin.
Using FirebaseDB is OK but If you want to deal with really complex data which this app can (In case to want to expand this app and want to add more and more features). I even Suggest if u are going with MS-SQL , Create your Own WebAPI to handle the requests.
All the Very Best for your App.

How do I receive the specific user data from firebase using phone number not by uid?

I have done phone authentication linked to my project but I am not pushing the data from android instead I have manually entered the user data in Firebase. And I want to retrieve the data from firebase using OTP verification and I just need to search the specific user data with phone number which I am entering while login. I want to show all fields to be displayed which are present in my firebase database into my android project.
I've tried many methods to receive the data but I am stuck... Please help me.
Database structure
Authentication panal
You need to logically bind your authenticated user and the data that you stored in your firebase. As per the image in your data base 'id' of the 'Users' are 1,2,.. like that. Instead of that you can use 'UID' of users as an an Id in your database. Go to your 'Authentication' section, you will see User UID against each registered user. Copy that and use as an ID while creating data in database. This will help you to get the data with reference like Users\. Hope this will solve your problem.

how to send user info which is stored in sqlite database to another user and how to store current location in sqlite

I am stuck at a point and can't figure it out how can I manage to send user's data which is stored in the database to another user with admin privileges after user just press a button in an app and display this info on admin's screen.
Till now I am done with the database to store user info during registration, I am new to android development and have just basic knowledge is there any better way in which i can possibly do that please let me know.
thanks
Yes, I assume you access your SQLite with a content provider/resolvers. You have to make them available to other apps, at which point they can access your data. Starting reading about it here:
https://developer.android.com/guide/topics/providers/content-providers.html
Think about why you can easily use content provider/resolver to see all gallery photos, it works the same way. It is because the photos are stored in a publicly available SQLite database and by using content provider you can access or even modify them.

Add to favourite

I'm working on book app, when the user clicks on a book on the list, my app gives the option to add that book to favorites.so the user can view the favorite books
but I don't know how to implement that..
Your question is a bit vague. I see two open questions here:
How to catch the user click and process the event?
How and where to store the book name/details?
For 1:
Just have your activity listing the books implement the corresponding event listener. See here: Android Doc - Input Events
For 2:
Depends on the amount of data you want to store if it is just a list of favorite book names Preferences might do. If you want to kep the option to extend the stored list with details fo each book then a SQLite database is your choice.
There is an Android Tutorial on how to persist data as well:
See here: Android Doc - Data Storage
And here we have a tutorial "Creating and using databases in Android".
Maintain a database for all the favourtes book. When ever user clicks on any just add that item in database and whenever requires to view the book just retrive it from the database and show it to the user so that the will be as you required.
You can store that values in 2 ways
Use Sqlite but some what coding is heavy for this.
Use serialization and deserialization to store data.

Categories

Resources