How to Upload PDF Files in Firebase Storage in Android?
Firebase is a mobile and web application development platform. It provides services that a web application or mobile application might require. Firebase provides secure file uploads and downloads for the Firebase application. This article explains how to build an Android application with the ability to select the pdf from the mobile phone and upload that pdf to the Firebase Storage.
Step by Step Implementation
Step 1: Create a New Project
To create a new project in Android Studio please refer to How to Create/Start a New Project in Android Studio. Note that select Java as the programming language. And add firebase to your project or you can refer to Adding Firebase to Android App.
Step 2: Add the dependency in the build.gradle (Module : app) file
Navigate to the Gradle Scripts > build.gradle (Module : app) and add the below dependency in the dependencies section.
implementation fileTree(dir: ‘libs’, include: [‘*.jar’])
After adding this dependency sync your project and now we will move towards its implementation.
Step 3: Working with the activity_main.xml file
Navigate to the app > res > layout > activity_main.xml and add the below code to that file. Below is the code for the activity_main.xml file.
Step 4: Working with the MainActivity.java file
Go to the MainActivity.java file and refer to the following code. Below is the code for the MainActivity.java file. Comments are added inside the code to understand the code in more detail.