How to Fetch Data From Firebase Firestore Database | Firebase Tutorial | Android Studio
Вставка
- Опубліковано 15 жов 2024
- Learn How to Retrieve user profile data in Firebase Firestore database in android studio. This is basic video tutorials on firebase databse where, we are going to take the data from the registration form and store them into firebase firestore database and reterive and display them in mainactivity.
This is part one of the video tutorials on Firebase firestore store the user data and retrieve it .
Part 1 of this video: • Store User Profile dat...
Previous Tutorials:
1. Firebase Authentication system part-1: • Login & Register Andro...
2. Firebase Authentication System Part-2: • Login & Register Andro...
Full Text Tutorials Post and Source Code: smallacademy.c...
Source:
firebase phone authentication android tutorial,firebase android authentication tutorial,android studio tutorial - firebase authentication (2019 version),#1 firebase phone authentication android tutorial - sign in,Login & Register Using Firebase,Android Studio Authentication Tutorials,login and register android studio,login and register android studio firebase,firebase authentication android,firebase authentication tutorial,android studio tutorial for beginners
#androidstudio #firebase #firestore
I knew nothing about android development until I watched your vids, thanks bro. I really appreciate that.
I would like to say thank you because I love how you deliver your lectures. you are an excellent programmer. You discuss the tutorial in an easy way that we can easily understand. I hope you will create more videos. GOD Bless you!
So nice of you
keep doing sir, we want many vidoes from firebase firestore ...pls keep continue to uploads videos.
Thnx man I know people don't show the support but rest assured that your tuto save lives
:)
These videos are really helpful. Keep those Firebase tutorials coming
Sure :)
my app crash if i sign out
i think its because of snapshot listener because i try to get userId but its null
i dont know why this happening because i close mainactivity when user sign out. any idea?
How can i make this in a fragment?
Its working when getting a string value... but app closes when getting an Integer value from firebase to text view.
i will stayed here in this channel wait for more tut.i learned much here.thanks
amazing tutorial man, i love so much. very simple and you explain everything you type so we can actually understand these built in functions. much appreciated
Amazing Tutorial Sir, but I have one doubt, I have learn making login and register by your tutorial but the problem is that when I press back button it again go to login page How should I stop this? please help....... I am new in Android Development
Help! i got error: 'java.lang.String com.google.firebase.firestore.DocumentSnapshot.getString(java.lang.String)' on a null object reference
Did you find the solution
so i implemented this on the profile fragment in my app, do i add it to fragment java file or profile fragment, either way its not working its just showing the textView. any suggestions?
this works fine but after I applied this changes.. whenever I registered a user and then click the log out button I always end up in register activity with the data that I had just registered also showing.. same if I start the process from Login then pressed logout I end up in Login activity with data also showing but this one is ok... it's the first 1 I cant accept because whenever I click the logout but I should be directed to Login not the register..do you have any fix for this..? thanks by the way for the great tutorial..
hello sir... its been a while i am following your videos and come to a problem where reference to same video my eventlisteners is inactive can be said (looks like commented) just the "new Eventlistnerand could not find the reason for that my app is crashing while i use the whole DocumentRefence code otherwise multiline Commenting the the DocumentReference code woks fine...help me!!!
i really like your video.
But i am getting error in fetching data in the android studio
I cant make that protected void onCreate method you have in the very beginning...is it because I am trying to do it in a fragment? trying to make the profile part of a navigation drawer.
this is the best tutorials on internet... keep going sir .
great video if the type saved in Firestore database is not a string and is a number how would you retrieve this number
Your tutorials are owesome. Please create tutorials on story app. Passing story from Firebase in Realtime to our app. Thanks
How can we get the multiple phone numbers that user saved in firestore?also, is there any way to get all phone numbers together so that we can send sms to all phone numbers at once?help me out with this please
When I directly jump from login page to profile I don't get the details in my profile but that doesn't happen same when I register with different id name..why?? Plz plz help
Thank you very much for the Firebase | Android Studio tutorial!! Very helpful, amazing
Can you please help me...my app is crashing..i can send you code if you want.........please reply...it's my college project and I am still stuck at login part
Seems there is one issue. The app runs fine. But after building the debug apk, the app doesn't work. What is the solution for this error.?
This is a open database . How do you authenticate user before writing and reading data from firestore
hi , after this code When I press the logout button, the application ends and destroys
bro can u help me out with the project your same project is not working in mine
there are many error will u help me in solving this
Your video has helped me a lot thanks but Do you have a sample image?
Sir, i can use the same code in fragment?
how do i delete data from firestore after deleting user in authentication in codess.. could u please help.
Sir sub collection se data kaise fetch krte hai.. uspe bhi ek video bana do... Plz.. using firestore firebase
its work good in activity
but in fragment it is crash .. why ?
hello bro... my app is calling the information from the firebase correctly but for some reason, when i click the logout button, my app crashes, do you have an idea why this is happening?
What error do you get ? Check if logout btn has the correct resources
@@SmallAcademy Hello, Thanks for the video :) I have the same problem. The error message is as follows and only occurs once i try to logout:
java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.String com.google.firebase.firestore.DocumentSnapshot.getString(java.lang.String)' on a null object reference
at com.example.firebasesetup.MainActivity$1.onEvent(MainActivity.java:49)
at com.example.firebasesetup.MainActivity$1.onEvent(MainActivity.java:46)
at com.google.firebase.firestore.DocumentReference.lambda$addSnapshotListenerInternal$2(com.google.firebase:firebase-firestore@@17.1.2:544)
at com.google.firebase.firestore.DocumentReference$$Lambda$3.onEvent(com.google.firebase:firebase-firestore@@17.1.2)
at com.google.firebase.firestore.util.ExecutorEventListener.lambda$onEvent$0(com.google.firebase:firebase-firestore@@17.1.2:42)
at com.google.firebase.firestore.util.ExecutorEventListener$$Lambda$1.run(com.google.firebase:firebase-firestore@@17.1.2)
at android.os.Handler.handleCallback(Handler.java:751)
For anyone having the same problem. I found a solution: The problem is that with the logout the user loses the permission to have access to the data. Therefore documentSnapshot is null and it throws a null object reference. Solution:
if(documentSnapshot == null){
Log.i("Error; ", e.toString());
}else {
username.setText(documentSnapshot.getString("Username"));
email.setText(documentSnapshot.getString("E-Mail"));
}
}
is this a good solution SmallAcademy?
@@lucafranceschetti8282 I had the same problem. Thanks for sharing solution.
@@lucafranceschetti8282 wats e on e.tostring
Can we upload data from one app and retrive the same data to another app in the same project?
hey brother. huge thanks for your awesome work. and can you please address my problem. as when it logs out the app crashes. it says "java.lang.NullPointerException:" in your case line number 39 and 43. as I only want to show the name of the user in the main activity. thanks
Please share you project source code and exact timestamp in the video
Hey ! I encountered the same exception as well, I found the solution: When you add SnapshotListner to Documentreference inside the ONEVENT function comes 2 arguments : either there will be exception(error) or documentsnapshot successfully retrieved so check exception if(e != null) as it can cause a crash and put snapshot access code inside ELSE statement.
if (e!=null){
Log.d("DocumentSnapshot","Error:"+e.getMessage());
}else {
//getting the string using key defined from the document snapshot
name.setText(documentSnapshot.getString("fullName"));
email.setText(documentSnapshot.getString("email"));
}
I hope you get it now
I got the same issue. I couldn't figure it out . Please help.
@@poojansoni497 did you manage to fix the problem?
@@poojansoni497 not working
@Override
public void onEvent(@Nullable DocumentSnapshot documentSnapshot, @Nullable FirebaseFirestoreException error) {
if (error!=null){
Log.d("DocumentSnapshot","Error:"+error.getMessage());
}else {
etNombre.setText(documentSnapshot.getString("Nombre"));
etEmail.setText(documentSnapshot.getString("Email"));
etPhone.setText(documentSnapshot.getString("Telefono"));
}
}
How can we read "number" from the database into integer??
do u know how can i fetch an array from firestore instad of just a string?
Does anyone get the source code? In the link which he gave .. I can't find...Please help if you find.
it's not retriving any data for me :( previous videos worked very well tho!! any help please!!
Same for me. did you fix the problem?
my data is store at firebase firestore but my data is not fetch from firestore.
I have done the las three videos but in this activity automatically mi app crash :(
hey just do the same thing but it doesn't work for me ... it doesn't throw any error but i can't see the email in the header of my App, i the firestore i can see the collection a created, i did this in my onComplete method in the login class coz i'm not using the register Activity.
Did ur problem solved?
Thanks for the tutorial, do you have a tutorial for mysql database connection?
Thanks in advance
merci ce votre tutto qui vient de m'aider pour mon travail de fin de cycle vous etes vraiment tres clair
Keep it up!
a fellow from Philippines~
Thank you teacher, everything is clear but I faced a problem with “getString” method
When I run the app , it show an error indicates that “ non-static method can not be referenced from a static context
How can i fix this error :( ??
same
did u got the solution?
public void onEvent(@Nullable DocumentSnapshot documentSnapshot, @Nullable FirebaseFirestoreException e) {
my this line was wrong thats why
I’m having the same problem, have you solved it ?
I have a error with get string, how can i solve this ?
what image asset has been used? how do we get it?
can you show us how to let the user download files from the app, then he go to another page (or activity) and access the file that is download it ?
and thank you very much i learned from your tutorials, you are the best i swear
Okay , but what kind of file is user downloading ? And is that file saved in firebase or other server ?
@@SmallAcademy PDF File, yes in fire base
like this example :
he will go to this page and will click the book or slides button to download after this he can go to the My Downloads page and see the files that already he download it
all videos related to firebase are best by you
Really appreciate these tutorials they have been really helpful!
How can we fetch all data from firestore from different unique user IDs
Can write this retriving code by kotlin??
Hello,
Did you show somewhere the related XML file?
Brother , I am getting two apps instead of one in my mobile when I install the app designed by your tutorials. can you help me why I am getting two apps?
Check your manifest and see if the LAUNCHER tag is set on two activity registrations
Hi really need your help, so when i create a user using firebase instead of the using the app, the login still works but the main activity doesnt fetch any details about the user
check if you have stored the data in firestore
I like this channel and i waiting for this tutorial to continue about delete and updates
thanks man for this short and really very helpful tutorial!
Thanks a lot for the tutorial. Everything works fine except when I log out it crashes. What could be the reason?
Try changing onCreate method in Main.java file. Works for me.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
fullName = findViewById(R.id.profileFullName);
email = findViewById(R.id.profileEmail);
phoneNum = findViewById(R.id.profilePhoneNum);
fAuth = FirebaseAuth.getInstance();
fStore = FirebaseFirestore.getInstance();
userID = Objects.requireNonNull(fAuth.getCurrentUser()).getUid();
DocumentReference documentReference = fStore.collection("users").document(userID);
documentReference.addSnapshotListener(this, new EventListener() {
@Override
public void onEvent(@Nullable DocumentSnapshot documentSnapshot, @Nullable FirebaseFirestoreException e) {
fullName.setText(documentSnapshot != null ? documentSnapshot.getString("fname") : null);
email.setText(documentSnapshot != null ? documentSnapshot.getString("email") : null);
phoneNum.setText(documentSnapshot != null ? documentSnapshot.getString("phone"): null);
}
});
@@lesaralen14 You saved me. Thank you so much for correcting.
@@leninsingh5264 hey help me plz my data is showing in the firebase but in my app it is not showing.... getUid may produce null pointer expection....
@@arushisharma6001 Sorry for late reply. Have you tried with the above code of @lesaralen14
@@leninsingh5264 thank you my problem was solved earlier ....🤭🤭
Thanks for the tutorial, can't wait for the next one
The tutorial was straight to the point
Great tutorial bro!! Can you provide link to next tutorial about upload images and retrieve
Thanks for the tutorial....!! I am waiting for Update and delete operation....
Hi, I've got a problem while trying to run the program, "cannot fit the requested classes in a single dex file", I searched in google for a solution, i found that its a very common problem that happens when you try to use firebase and firebasestore at the same time, do you happen to know any solutions?
Still having problem ?
@@SmallAcademy yep
I've had the same issue. I followed stackoverflow.com/questions/48249633/errorcannot-fit-requested-classes-in-a-single-dex-file-try-supplying-a-main-dex and it solved the issue
Have you made the tutorial on "how to Fetch Image file from Firebase database? If yes, let me give the link of that video, thank you.
Not yet but soon
@@SmallAcademy when? we are still waiting
Thanks for the tutorial sir! create more video like this! maybe CRUD sir, Thanks!!!!!! from Philippines.
where is image uplaod in user profile
May I ask why the getUid may return null value? How to solve that?
As well as that getString may possible return null value
Can you show us on how to do a transaction to dummy website?
how to do all these in a fragment?
help!
When i Logout App crashes
Sir I have done all the task related to the last three videos, but while doing this I'm facing some problem. I have done all according to u, but when installed the app, it crash automatically. Please Help me
Share source code
When will you upload tutorial on uploading profile picture?
Please continue sir.
Your videos are awesome sir 👌
Its coming soon ... 😀
@@SmallAcademy Can't wiait to see it
@@SmallAcademy waiting for the profile picture uploading tutorial??
Greets from Indonesia sir, so im already try ur tutorial and meet some error, my data from firestore didnt show up but that text view already gone, please help me fix it thanks
Please share the source code on github.
@@SmallAcademy i already realized my issue, so i make document id without using user id from auth firestore hehe, thanks a lot for ur tutorial, its amaziing hehe .And would you make a tutorial about make app like facebook? Thaanks
same for me ! can you tell me how you fixed it please!! maybe share the code with me..
So i just realized ,You havent make next tutorial for changing user profile image yet? Using Firebase Storage based on userID ? Would you make the tutorial please?
I am sorry , i m at middle of my exam and will be busy till jan 1 , sure lots of tuts are coming in 2020 ,
@@SmallAcademy okay sir, goodluck for your exam btw
keep going please, you are an amazing teacher
Did you make a video on how to save Bitmaps? Thanks! :)
Dude, you've missed one thing in all your tutorials, which is that there is no session management, even in device's back button there is no handling performed, please let me know how can i do that?
What do you mean ? The firebase automatically handle the sessions for users.
@@SmallAcademy but, when I click on back button after successful login or registration, then it shows me again register activity and same goes with login which isn't acceptable. Device back button handling should be performed.
@@hinaallauddin8256 hey help me plz my data is showing in the firebase but in my app it is not showing.... getUid may produce null pointer expection
Great video! Can you upload a tutorial video of uploading an image into firestore
Does this tutorial use Architecture pattern?
Sir can we retrieve the data from firestore and store them to another variable and use it sir
How to store them to another variable
Sure you can, check firebase documentation for now , later i might make videos on that
thank you. that was helpful and it would be great if you create more videos about Firebase
Sure
Class not found error : com.mediatek.cta.ctaHttp
During fetch data from firebase.
update firebase dependency to latest version from build.gradle
How can we implement this in the fragment
Please Help!!!
its a similar process
Amazing tutorial sir deserved a big thumbs up.. by the way can you make a tutorial for fetching data from different user ? Because im having a hard time getting other user's id
It's helpful.If you could make tutorial video to retrieve data from firebase cloud store to a fragment class of an application which uses MVVM architecture.
Will try
plz help me to reslove this type of problem
Nice tutorials....
Please make a tutorial on e-Learning app.
Sure, stay tuned
Your code working I've followed; have you any tutorial about filestore recycler view and event click listener?
Yeah, please go through the playlist
@@SmallAcademy again searched your playlist but not found that type of video
how do i add the listener if i am using a fragment?(onsnapshot)
do you find the answer?
Thank you so much Sir very helpful
bro All before tutorial were successful but i got error in this tutorial. Can please help me?
Whats the error ?
@@SmallAcademy While I run the app it get crash!
anyone knows whats the difference between realtime database and cloud firebase? can please explain in baby language to me?
they are practically the same but firestore comes with more advanced architecture and supports more operation than traditional RB. if you want to learn more check firebase documentation.
sir, im having problem when I log out my acc the second time it crashes. need help
just add currentuser.signout() method after clickon button
@@softprogramming thank you
document (userId ) is not fetching data.
Did ur problem solved?
Hey! Can you make a tutorial on how to connect a feedback data (eg rating, comments) from the customer using Android studio with firebase?
Sure, but i may need more information, is it similar to movie rating app where user can comments and rate movies etc ??
@@SmallAcademy Yah. It's something like that. Thanks :)
Okay got it , stay tuned for the tutorial
When i click in logout the app crash, u can help me ?
try to change in MainActivity
FirebaseAuth.getInstance().signOut(); //logout of user
to
fAuth.signOut(); //logout of user
How to display add details enter by user inside app (retrive from firebase),in one activity of fragment??can u help sir
You follow the same procedure that i have used in this series.
@@SmallAcademy Hello plz help me I am getting a Problem that my data is not captured means it is not visible in the main activity data is captured in the firestore but I am not getting it in my app
getUid may produce Null pointer expection
Thanks soo much man!! Helped soo much!
Can i get the login source code?