Upload PDF File in Firebase - Android | Java | Android Studio Tutorial - Quick + Easy

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
hi today i'm gonna show you how to upload pdf file in fireways so let's start open your android studio now click on start a new android studio project select empty activity click on next name of your application here we select language java click on finish so first we work on design click on res layout activity main.xml here we use relative layout and add one background image i already store one image in drivable folder then we use one edit text then we add one button now next step is to connect the firebase to our app click on tools firebase click on real-time database save and retrieve data connect to firebase as you can see that our app is connected to a firebase now click on add the real-time database to our app accept changes all the dependencies set up correctly now click on storage upload and download a file with cloud storage here we click on add storage to your app accept changes as you can see that all the storage dependencies set up correctly now click on build.gradle app level now we will use upgrading version of our dependencies so here we change 19.4.0 for database 19.2.0 for storage and 19.3.2 for earth and click on sync now now open your browser and open console firebase console here you can see our upload pdf project is created remember your firebase login id and your android studio login id must be saved click on real-time database here we create database click on create database and selecting start in test mode and enable click on rules here we change the rule true and click on publish as you can see rule published i changed both read and write true it means you can read any file from firebase and you can upload any file to the firebase now click on storage get a starter next done here we also change the rules click on rules we allow read and write both and click on finish so here we change our rules now back to our android studio click on main activity first we creating one class and name it put pdf and this class and this class we are creating to get the data from the firebase and to upload the data to the firewase we create constructor first we create an empty constructor and then we create parameterize constructor select both now create getter setter and select both name and url so that this getter and setter will help us to get the data from the firebase and store the data in the firebase now click on mainactivity.java first we get the reference of edittext and button from xml file by using find view by id now we create a storage reference and database reference object so inside this database reference we pass the path now initially we disable our button so button dot set enabled here we pass false so when we click on edit text it will select the file from the local storage so here we use edit text dot set on click listener here we create one method that will select the file from the local storage so name it select pdf so here we use intent and this intent will pick the file from the storage type then we set the action activity for result and here we use create chooser so after we select the file from the storage it will store here and then we will store in the firebase so here we pass intent and pass request code now we will create one override method on activity result and this method perform the main functionality so here we check one condition so if our data is okay our result is okay and data is not equals to null then we will upload the file in the firebase so first we enable our button here we pass through then set the text in edit text and then when i click on button it will upload the file to the firebase here we create one method upload pdf file and here we pass our data now create this method so this method put the data to the firebase we create one progress dialog so when our file is upload in firebase one progress dialog will be displayed now we will create one storage reference object and here we use store difference that we created before here you can see the storage difference dot child here we pass our path and with this path you can attach any system functions like system dot current time in milliseconds and you can attest the extension like dot pdf now we use this reference object to put the file in the firebase here we use a function called put file and pass the parameter data and then we call one function called add on success listener and use another method on progress listener so this on success method will call when our file is successfully uploaded to the storage so inside this on success method i'll store the url and the name of the file in the real time database now here we create the object of our put pdf class now we use database reference and this will store the data to the real time database now database reference dot push dot get cable create one unique key and inside this key we set our value now we will create one toast message that was displayed the file is uploaded and we dismiss our progress well now inside the on progress method we will show the progress of our download so progress will be display in percentage now click on manifest file here we add some permissions like internet permission and read external storage permission and open your browser so click on project settings download google services.json and paste this google.json service in your android studio project here we click on project and paste this inside the app now run the project here you can see the output so when i click on edit text here we select the pdf file from our local storage you can change the name if you want and click on upload file button now file is uploading now we will see in firebase console so open your browser so here you can see our pdf file is uploaded in real time database so here you can see one unit key is created and inside this unique key we save the name and url of our pdf file now click on storage here you can see our pdf file is uploaded with the extension dot pdf in my next video i will show how to fetch the pdf file from firebase and display in android thank you for watching my video please like and subscribe my channel and share your feedback in comment section thank you
Info
Channel: Learn With Deeksha
Views: 11,354
Rating: undefined out of 5
Keywords: Android, Android Studio, Beginners, App, HowTo, New, 2020, Android Studio Tutorial for beginners, Android studio tutorial 2020, android studio app development, upload pdf file in firebase, upload pdf to firebase android, firebase functions upload file to storage, upload file to firebase storage android, how to retrieve pdf file from firebase and display it in android, firebase upload file
Id: lY9zSr6cxko
Channel Id: undefined
Length: 16min 18sec (978 seconds)
Published: Wed Sep 09 2020
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.