How to upload Image in Firebase Realtime Database in Android Studio

Опубликовано: 03 Июль 2020
на канале: Android Development Tutorials
1,901
23

Installation & Setup on Android

Connect your App to Firebase

If you haven't already, add Firebase to your Android project.

In your project-level build.gradle file, make sure to include Google's Maven repository in both your buildscript and allprojects sections.

Create a Database
If you haven't already, create a Firebase project: In the Firebase console, click Add project, then follow the on-screen instructions to create a Firebase project or to add Firebase services to an existing GCP project.

Navigate to the Database section of the Firebase console. You'll be prompted to select an existing Firebase project. Follow the database creation workflow.

Select a starting mode for your Firebase Security Rules:

Test mode
Good for getting started with the mobile and web client libraries, but allows anyone to read and overwrite your data. After testing, make sure to review the Understand Firebase Realtime Database Rules section.

To get started with the web, iOS, or Android SDK, select test mode.

Locked mode
Denies all reads and writes from mobile and web clients. Your authenticated application servers can still access your database.

Click Done.

When you enable Realtime Database, it also enables the API in the Cloud API Manager.

Add the Realtime Database SDK to your app

Add the dependency for the Realtime Database Android library to your module (app-level) Gradle file (usually app/build.gradle):

Java

implementation 'com.google.firebase:firebase-database:19.3.1'


Add the Cloud Storage for Firebase SDK to your app
Add the dependency for the Cloud Storage for Firebase Android library to your module (app-level) Gradle file (usually app/build.gradle):

Java

implementation 'com.google.firebase:firebase-storage:19.1.1'